When we are not given the external Document No. we should not allow to insert Sales lines in the sales order, I am attaching my code what I have tried but I did not get it and can you share me any example how we can do it.
trigger OnAfterGetCurrRecord()
var
myInt: Integer;
SalesLine: Record "Sales Line";
Value1: Text[20];
Text000: Label 'The external document No. have to be given';
begin
if Rec."External Document No." = '' then
Rec.FieldError("External Document No.", Text000);
end;