I have created a new table with different fields, 1 of them is CustAccount
, in the form i want to create a column next of CustAccount
showing the CustName
.
I want to display
the Customer Name, based on the selection of the CustAccount.
I have tried using the existing method name
on the table CustTable
, which contains the following code:
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;
}
This displays a customer name, except not based on the CustAccount selection. I am thinking about copying the code to a new method on my new table. How do I edit the code to accomplish this?
Or is there a better way?
You don't want to copy that method to your table. Instead refer to it by putting this method on your table:
// BP deviation documented
display CustName name()
{
return CustTable::find(this.CustAcccount).name();
}