The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.
NAME Method (FieldRef)
Gets the name of a field as a string.
Name := FieldRef.NAME
The FieldRef of the field in the record.
Property Value/Return Value
Type: Text Constant or Code
The name of the field given as input.
The CAPTION Method (FieldRef, TestPage Field) method retrieves the Caption Property of a field. To enable your application for multilanguage functionality, you must use the FIELDCAPTION Method (Record) instead.
This method is similar to the FIELDNAME Method (Record) method.
The following example opens the Customer table as a RecordRef variable that is named CustomerRecref. The FIELD Method (RecordRef) creates a reference to the fields in the table and stores the FieldRef in the MyFieldRef variable. The code loops through field 1 through 5. For each field, the NAME method retrieves the name of the field and stores the value in the varName variable. The field number and the value in the varName variable are displayed in a message box. This example requires that you create the following global variables and text constant.
|Text constant||ENU value|
|Text000||The name of field %1 is "%2".\|
FOR i := 1 TO 5 DO BEGIN CustomerRecref.OPEN(DATABASE::Customer); MyFieldRef := CustomerRecref.FIELD(i); varName := MyFieldRef.NAME; MESSAGE(Text000, i, varName); CustomerRecref.CLOSE; END;