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.
Calls the OnValidate trigger for the field that you specify.
Syntax
Record.Validate(Field: Any [, NewValue: Any])
Parameters
Record
Type: Record
An instance of the Record data type.
Field
Type: Any
A field together with associated triggers.
[Optional] NewValue
Type: Any
The value to insert into Field.
Code example
The following example shows how to use the Validate
method to validate a field in a record. The example uses the Customer
table and validates the fields "No."
, Name
, "Phone No."
, Address
, and City
. The Validate
method not only assigns the value but also triggers any validation logic defined for the field in the table. This ensures that the data adheres to any business rules or constraints defined in the table. The CustomerRec.Insert()
method is called to insert the newly created and validated record into the database. This step commits the data, making it available for use in the system.
codeunit 50222 MyCodeunit
{
local procedure ValidateCustomerFields()
var
CustomerRec: Record Customer;
begin
// Initialize the record
CustomerRec.Init();
// Validate and set fields
CustomerRec.Validate("No.", '1234');
CustomerRec.Validate(Name, 'Windy City Solutions');
CustomerRec.Validate("Phone No.", '555-444-333');
CustomerRec.Validate(Address, '1241 Druid Avenue');
CustomerRec.Validate(City, 'Windy City');
// Insert the record into the database
CustomerRec.Insert();
end;
}