VALIDATE Function (Record)
Calls the triggers for the field you specify.
A field with associated triggers
Type: Must be the same data type as Field, or a data type that is convertible.
The value to insert if Field.
This example shows how to use the VALIDATE function.
When you enter an account number in a ledger, some table trigger code is executed to transfer the name of the account from the chart of accounts.
If you enter an account number in a batch job, the code which transfers the name of the account is not automatically executed. The following code specifies that the appropriate field-level trigger code must be executed.
This example requires that you create the following variable.
GeneralLedgerEntry.VALIDATE("G/L AccountNo", '100'); // This corresponds to: GeneralLedgerEntry."G/L AccountNo" := '100'; GeneralLedgerEntry.VALIDATE("G/L AccountNo");
The VALIDATE function is useful for centralizing processing and thereby making your application easier to maintain.
For example, if the OnValidate trigger of the Total Amount field performs a calculation that uses values from three other fields as operands, the calculation must be performed again if the contents of any of these fields changes.
You should avoid entering the calculation formula in the OnValidate triggers of each field because this can create errors if the calculation formula has to be changed later and you have to update the code in all the triggers. Instead, you should enter the calculation formula in the OnValidate trigger of only one of the fields and call this trigger code from the OnValidate triggers of the other fields.