Sunday, March 17, 2019

Modify Field value using RecordRef & FieldRef

Hello Friends,

You can modify any table field value using RecordRef and FieldRef

A RecordRef object references a record in a table. Typically, you use a RecordRef object in functions that must apply to more than one table, not to a specific table. For example, you could use a RecordRef object in a function that loops through several tables or as a parameter of a function that is called for records of different tables.
The RecordRef object can refer to any table in the database. Use the OPEN Function (RecordRef) to use the table number to select the table that you want to access, or use the GETTABLE Function (RecordRef) to use another record variable to select the table that you want to access.
If one RecordRef variable is assigned to another RecordRef variable, then they both refer to the same table instance.
Example of code to modify field value using record ref & field ref variable
********** Sample Code to Modify Record using Record Reference and Modify the field value using Field Ref *************************

IF STRPOS(FORMAT(ApprovalEntry."Record ID to Approve"),'Gen. Journal Line') <> 0 THEN BEGIN
  RecRef_lRecRef.GET(ApprovalEntry."Record ID to Approve");
  FieldRef_lFrf := RecRef_lRecRef.FIELD(50084);
  FieldRef_lFrf.VALUE(TRUE);
  RecRef_lRecRef.MODIFY;
  RecRef_lRecRef.CLOSE;
END;

// ApprovalEntry."Record ID to Approve" à Record ID field and contain value like ('Gen. Journal Line :Default,Default,10000')

Name
DataType
Subtype
Length
RecRef_lRecRef  
RecordRef  

FieldRef_lFrf       
FieldRef     


No comments:

Post a Comment