Field Method

Gets a FieldRef for the field that has the number FieldNo in the table that is currently selected. If no field has this number, the method returns an error.


Field :=   RecordRef.Field(FieldNo: Integer)


 Type: RecordRef
An instance of the RecordRef data type.

 Type: Integer
The number that the field has in the table that is currently selected. This is the field for which you want the FieldRef.

Return Value

 Type: FieldRef
A new FieldRef of the record


This method returns an error if the record is not opened and if the field is not found.

You might obtain better performance by using the FIELDINDEX Method (RecordRef).


The following example opens table 18 (Customer) as a RecordRef variable that is named MyRecordRef. MyRecordRef uses the FIELD method to create a reference to the No. field (field 1). The value in the No. field is then set to a specified record No. In this example, the record is set to 30000. The FIND Method (RecordRef) records for record 30000. If record is found, the FIELD method retrieves the value in the Name field (field 2), stores it in the varOldName variable and displays it in a message box. The VALUE Method (FieldRef, TestPage Field) changes the value in the Name field to a new name. In this example, the new name is ‘Contoso’. The table is then modified to reflect this change and the new value in the Name field is retrieved and displayed in a message box. You can specify any record in the table and change the value in the Name field.

    MyRecordRef: RecordRef;
    MyFieldRef: FieldRef;
    varOldName: FieldRef;
    varNewName: Text;
    MyRecord: Code;
    MyRecord := '30000';  
    varNewName := 'Contoso';  
    MyFieldRef := MyRecordRef.FIELD(1);  
    MyFieldRef.VALUE := MyRecord;  
    if MyRecordRef.FIND('=') then begin  
      varOldName := MyRecordRef.FIELD(2);  
      MESSAGE('Old Name: %1', varOldName);  
      varOldName.VALUE := varNewName;  
      MESSAGE('New Name: %1', MyRecordRef.FIELD(2));  

See Also

RecordRef Data Type
Getting Started with AL
Developing Extensions