Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Version: Available or changed with runtime version 1.0.
Sets or gets the value of the field that is currently selected. This method returns an error if no field is selected.
Syntax
[Value := ] FieldRef.Value([NewValue: Any])
Note
This method can be invoked using property access syntax.
Parameters
FieldRef
Type: FieldRef
An instance of the FieldRef data type.
[Optional] NewValue
Type: Any
Return Value
[Optional] Value
Type: Any
Remarks
If you omit NewValue, the method returns the current value of the field.
For an initialized FieldRef, the default calls Format(FieldRef) and Format(FieldRef.Value) return the same text. Neither uses the field's DecimalPlaces property. For example, with the regional format set to English (United States), Format(Rec.Field) returns 1,234.50 for a Decimal field with DecimalPlaces = 2:2 and the value 1234.5. Both Format(FieldRef) and Format(FieldRef.Value) return 1,234.5 for the same field.
Example
The following example opens table 18, the Customer table, a RecordRef variable that is named CustomerRecref. The Field Method (RecordRef) creates a FieldRef for the first field (No.). The reference to the field is stored in the MyFieldRef variable. The Active Method (FieldRef) method determines whether the field is enabled. If the field is enabled, then the record that is identified by the number in the CustomerNo variable is selected. The MyFieldRef variable is updated to refer to the second field (Name). Then the value in the second field is changed to Contoso. The Modify Method (RecordRef) modifies the record in the table to reflect the change. MyFieldRef.Value retrieves the new name and displays it in message box.
var
MyFieldRef: FieldRef;
CustomerRecref: RecordRef;
CustomerNo: Code;
Text000: Label 'Customer name has changed to %1.';
begin
CustomerNo := '50000';
CustomerRecref.Open(18);
MyFieldRef := CustomerRecref.Field(1);
if MyFieldRef.Active then begin
MyFieldRef.Value(CustomerNo);
MyFieldRef := CustomerRecref.Field(2);
MyFieldRef.Value('Contoso');
CustomerRecref.Modify;
Message(Text000, MyFieldRef.Value);
end;
end;
Related information
FieldRef Data Type
Get Started with AL
Developing Extensions