显示方式客户名称

Display method Customer Name

我创建了一个包含不同字段的新 table,其中 1 个是 CustAccount,我想在 CustAccount 的下一列创建一个显示 [=13] 的表格=].

我想 display 客户名称,基于 CustAccount 的选择。

我尝试在 table CustTable 上使用现有方法 name,其中包含以下代码:

display CustName name()
{
    DirPartyTable   dirPartyTable;
    CustName        custName;
    boolean         isSet = false;

    try
    {
        if (this.hasRelatedTable(identifierStr(DirPartyTable_FK)))
        {
            dirPartyTable = this.relatedTable(identifierStr(DirPartyTable_FK)) as DirPartyTable;

            //Check to make sure the fields we are accessing are selected.
            if (dirPartyTable && dirPartyTable.isFieldDataRetrieved(fieldStr(DirPartyTable, Name)))
            {
                custName = dirPartyTable.Name;
                isSet = true;
            }
        }
    }
    catch (Exception::Error)
    {
        isSet = false;
    }

    //If we aren't joined to DirPartyTable or it isn't selected, then do a query to get it.
    if(!isSet)
    {
        custName = DirPartyTable::getName(this.Party);
    }

    return custName;
}

这会显示客户名称,但不基于 CustAccount 选择。我正在考虑将代码复制到我的新 table 上的新方法。我如何编辑代码来完成此操作?

或者有更好的方法吗?

是的,这个方法Name() 工作正常。还有其他方法。

我留下两种方法来得到你想要的:

CustTable     CustTable;
AccountNum    pCust;
str           cName;            
DirPartyTable DirPartyTable;

;

//First option     
pCust = "YourCustomer";    
Select * from CustTable where CustTable.AccountNum == pCust;
cName = CustTable.name(); //Get Name
//First option END

//Second option
pCust = "YourCustomer";    
Select Party from CustTable where CustTable.AccountNum == pCust
    join DirPartyTable where DirPartyTable.RecId == CustTable.Party;
cName = DirPartyTable.Name; //Get Name
//Second option END

您不想将该方法复制到您的 table。而是通过将此方法放在您的 table:

上来引用它
// BP deviation documented
display CustName name()
{
    return CustTable::find(this.CustAcccount).name();
}