Hi Guys,
New to AL and am sure this must be simple but have been looking at this all evening but not getting anywhere.
I have a new table ContractTBL and which contains a field ContractNo Text[80].
When validating the card entry in I need the system to check for a unique entry.
I am guessing I need an OnValidate trigger on the ContractNo field but just cannot find a sample of the code to give me a start.
Found the following on the forum and have amended with my table.field etc. but it always fails the validation even when a unique record is entered.
Would really appreciate any comments on this.
trigger OnValidate()
Var
ContractNo: Record ContractTBL;
begin
ContractNo.SetRange("Contract No", "Contract No");
ContractNo.SetFilter("Contract No", '<>%1', "Contract No");
if not ContractNo.IsEmpty() then
Error('The Contract No. must be unique');
end;