Use Validate() instead of direct field assignment (PC0037)
When you assign a value to a record field with :=, the AL runtime writes the value directly without executing the field’s OnValidate trigger. Any event subscribers attached to that trigger (from Microsoft, partners, or per-tenant extensions) are silently skipped.
This matters because other extensions may rely on field validation to enforce business rules, calculate derived values, or perform compliance checks. Bypassing Validate() can cause data integrity issues that are difficult to trace: values that should have been recalculated remain stale, cross-field constraints are not enforced, and downstream subscribers never fire.
Use Validate() to assign field values. This ensures the full validation chain executes regardless of which extensions are installed.
Example
procedure SetUnitPrice(var SalesLine: Record "Sales Line"; NewPrice: Decimal)
begin
SalesLine."Unit Price" := NewPrice;
SalesLine.Modify(true);
end;Replace the direct assignment with Validate():
procedure SetUnitPrice(var SalesLine: Record "Sales Line"; NewPrice: Decimal)
begin
SalesLine.Validate("Unit Price", NewPrice);
SalesLine.Modify(true);
end;Code fix
The code fix replaces Record."Field" := Value with Record.Validate("Field", Value) preserving the original value expression as the second argument.
Exception
The rule is not raised when the record variable is declared as temporary. Temporary records do not persist and their OnValidate triggers are typically irrelevant.
Use a pragma when you have a documented reason to bypass validation on a non-temporary record:
#pragma warning disable PC0037 // Justify why we don't execute the validation on the "Unit Price" field
SalesLine."Unit Price" := NewPrice;
#pragma warning restore PC0037