FieldRef.Validate([Any]) Method
Version: Available or changed with runtime version 1.0.
Use this method to enter a new value into a field and have the new value validated by the properties and code that have been defined for that field.
Syntax
FieldRef.Validate([NewValue: Any])
Parameters
FieldRef
Type: FieldRef
An instance of the FieldRef data type.
[Optional] NewValue
Type: Any
The value to insert in the field.
Remarks
The Validate method first checks any TableRelation Property, and then executes the OnValidate (Fields) Trigger of the field.
If you omit NewValue, the method validates the current value.
This method is like the Validate Method (Record).
Example
The following example opens table 17 (G/L Entry) as a RecordRef that is named EntryRecref. The FindFirst Method (RecordRef) searches for the first record in the table. The Field Method (RecordRef) sets the field to 3, which is the G/L Account No. field. The VALIDATE method validates and inserts the specified value (1210) into the field. The Modify Method (RecordRef) modifies the table. A message that indicates the G/L Account No. field has changed is displayed. To show that the code in the OnValidate trigger is executed, design the G/L Entry table and add the following code to the G/L Account No. – OnValidate trigger: Message('The OnValidate trigger is called.');
var
MyFieldRef: FieldRef;
EntryRecref: RecordRef;
Text000: Label 'The G/L Account No. for record %1 is %2.';
Text001: Label 'The G/L Account No. for record %1 has changed to %2.';
begin
EntryRecref.Open(17);
if EntryRecref.FindFirst then begin
MyFieldRef := EntryRecref.Field(3);
Message(Text000, EntryRecref.RecordId, MyFieldRef.Value);
MyFieldRef.Validate('1210');
EntryRecref.Modify;
Message(Text001, EntryRecref.RecordId, MyFieldRef.Value);
end;
end;
Related information
FieldRef Data Type
Get Started with AL
Developing Extensions