RecordRef.GetTable(Record) Method

Version: Available or changed with runtime version 1.0.

Gets the table of a Record variable and causes the RecordRef to refer to the same table.

Syntax

 RecordRef.GetTable(Rec: Record)

Parameters

RecordRef
 Type: RecordRef
An instance of the RecordRef data type.

Rec
 Type: Record
Use this record variable to specify the table to which the RecordRefVar refers.

Remarks

Any filters that are applied to the RecordVar are also applied to the RecordRefVar.

Another way to select the table to which a RecordRef refers is to use the Open Method (RecordRef) and specify a table number in the parameters.

Example

The following example is an excerpt from codeunit 8, AccSchedManagement. It iterates through records in the G/L Account table. It sets some values on the fields of a new record in the Acc. Schedule Line table based on the current G/L Account record and inserts the new record into the Acc. Schedule Line table. It calls GetTable to cause a RecordRef variable to refer to the same table as the new Acc. Schedule Line record, and then calls the LogInsertion method from codeunit 423, Change Log Management to log the change. The LogInsertion method requires a RecordRef as a parameter.

This example assumes that the AccSchedLineNo variable has been assigned a value previously in the code.

var
    AccSchedLine: Record "Acc. Schedule Line";
    AccSchedLineNo: Integer;
    GLAcc: Record "G/L Account";
    RecRef: RecordRef;
    ChangeLogMgt: Codeunit "Change Log Management";
begin 
    if GLAcc.Find('-') then  
      repeat  
        AccSchedLine.Init;  
        AccSchedLine."Line No." := AccSchedLineNo;  
        AccSchedLineNo := AccSchedLineNo + 10000;  
        AccSchedLine.Description := GLAcc.Name;  
        if GLAcc."Account Type" IN [GLAcc."Account Type"::Posting,GLAcc."Account Type"::Total,GLAcc."Account Type"::"End-Total"] then begin  
          AccSchedLine.Totaling := GLAcc."No.";  
          AccSchedLine."Row No." := CopyStr(GLAcc."No.",1,MaxStrLen(AccSchedLine."Row No."));  
        end;  
        if GLAcc."Account Type" IN [GLAcc."Account Type"::Total,GLAcc."Account Type"::"End-Total"] then  
          AccSchedLine."Totaling Type" := AccSchedLine."Totaling Type"::"Total Accounts"  
        else  
          AccSchedLine."Totaling Type" := AccSchedLine."Totaling Type"::"Posting Accounts";  
        AccSchedLine.Insert;  
        RecRef.GetTable(AccSchedLine);  
        ChangeLogMgt.LogInsertion(RecRef);  
      until GLAcc.Next = 0;  
end;

RecordRef Data Type
Get Started with AL
Developing Extensions