The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.
ACTIVE Method (FieldRef)
Checks whether the field that is currently selected is enabled.
Ok := FieldRef.ACTIVE
Refers to the current field.
Property Value/Return Value
True if the field is enabled; otherwise, false.
Each field in a record can be set as enabled or disabled in the table description.
You cannot use a disabled field because disabled fields cannot contain data.
This method is like the FIELDACTIVE Method (Record) method.
The following example opens table 18 (Customer) as a RecordRef variable that is named Recref. The FIELD Method (RecordRef) uses Recref to create a FieldRef variable that is named MyFieldRef. MyFieldRef sets a reference to the first field (field 1) in the table. The SETRANGE Method (FieldRef) sets a filter that selects record 30000. The FIND Method (RecordRef) selects the record and then loops through fields1 through 6. For each field, the ACTIVE method determines whether the field is enabled. If the field is enabled, a message that states that the field is enabled is displayed. Otherwise, a message that states that the field is not enabled is displayed.
You can use the name of the table instead of the table number to open the table by using the following syntax: Recref.OPEN(DATABASE::Customer).
This example requires that you create the following global variables and text constantss.
|Text constant||ENU value|
|Text000||Field %1 is enabled.|
|Text001||Field %1 is not enabled.|
Recref.OPEN(18); MyFieldRef := Recref.FIELD(1); MyFieldRef.SETRANGE('30000'); Recref.FIND('-'); FOR i := 1 TO 5 DO BEGIN MyFieldRef := Recref.FIELDINDEX(i); IF MyFieldRef.ACTIVE THEN MESSAGE(Text000, i) ELSE BEGIN MESSAGE(Text001, i) END; END;