我创建了一个包含不同字段的新表格,其中一个是CustAccount
,我希望在CustAccount
旁边创建一个显示CustName
的列。
我希望根据CustAccount的选择display
客户名称。
我尝试使用表name
上的现有方法CustTable
,该方法包含以下代码:
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选项。我正在考虑将代码复制到我的新表上的新方法。如何编辑代码来完成此任务?
或者有更好的方法吗?
答案 0 :(得分:4)
您不想将该方法复制到您的表格中。而是通过将此方法放在您的桌子上来引用它:
// BP deviation documented
display CustName name()
{
return CustTable::find(this.CustAcccount).name();
}
答案 1 :(得分:0)
是的,这种方法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