Hi,
There is no standard procedure to check whether the external document no is used or not when adding data into the field.
You can go for customization below is the logic that you can add in page extension of Sales Order.
modify("External Document No.")
{
trigger OnAfterValidate()
var
Rec_CustomerLedgerEntry: Record "Cust. Ledger Entry";
Rec_SalesOrder: Record "Sales Header";
begin
Clear(Rec_CustomerLedgerEntry);
Rec_CustomerLedgerEntry.Reset();
Clear(Rec_SalesOrder);
Rec_SalesOrder.Reset();
if Rec."External Document No." <> '' then begin // To check if the external document no is blank or not.
// To check the external document no is used and posted in customer ledger entry
Rec_CustomerLedgerEntry.SetRange("External Document No.", Rec."External Document No.");
if Rec_CustomerLedgerEntry.FindFirst() then begin
if Confirm('External Document No is used already and it is posted ', false) then
Rec.Modify(false)
else
Clear(Rec."External Document No."); // If client says no then it clears the filled data
exit;
end;
// To check the external document no is used in Sales Header.
Rec_SalesOrder.SetRange("External Document No.", Rec."External Document No.");
if Rec_SalesOrder.FindFirst() then begin
if Confirm('External Document No is already in used in Sales Order', false) then
Rec.Modify(false)
else
Clear(Rec."External Document No.");
end;
exit;
end;
end;
}
If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much