selectRefRecord() method on table buffers.
The selectRefRecord() on table buffers can be used to retrieve the reference record accociated with a particular field. The underlying implementation of the method takes care of selecting the correct record based on the relation between the referenced field and the parent table.
Let us take an example.
Suppose we want to select the CustGroup associated with a SalesTable record.
The normal way someone will do that is,
The same can be achieved using the selectRefRecord() method as well,
Both the implementation has the same the same number of lines of code but selectRefRecord() comes in handy when the referenced table doesn't have a seperate find() method.
Let us take an example.
Suppose we want to select the CustGroup associated with a SalesTable record.
The normal way someone will do that is,
SalesTable salesTable;
CustGroup custGroup;
;
select firstonly salesTable;
custGroup = CustGroup::find(salesTable.CustGroup);
print custGroup.CustGroup;
print custGroup.Name;
The same can be achieved using the selectRefRecord() method as well,
SalesTable salesTable;
CustGroup custGroup;
;
select firstonly salesTable;
custGroup = salesTable.selectRefRecord(fieldnum(SalesTable, CustGroup));
print custGroup.CustGroup;
print custGroup.Name;
Both the implementation has the same the same number of lines of code but selectRefRecord() comes in handy when the referenced table doesn't have a seperate find() method.
Comments