web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

How add only unique value in External Doc field in Sales order?

(0) ShareShare
ReportReport
Posted on by 238

Hello Experts

in sales Order page there is Field External Document No. if we tried to enter value in page  that already added and preseent in sales header table means if this field already have value in table Sales Header it should not allow same value to be entered I am unaware how to achive  cah you please help me i tried following code but stuck on validate of Ecternal DOc no. of page

thnaks in Advance Experts

field("Ext Doc No."; Rec."Ext Doc  No.")
            {
                ApplicationArea = All;
                //FieldPropertyName = FieldPropertyValue;
                trigger OnValidate()
                var
                    salesH: Record "Sales Header";
                begin
                    salesH.Reset;
                    SalesH.SetRange(salesH."No.", Rec."No.");
                    if SalesH.findfirst then begin
????


                    end;

                end;
            }
  • Verified answer
    Mohana Yadav Profile Picture
    61,248 Super User 2026 Season 2 on at

                       salesH.Reset;

                       SalesH.Setrange("Document Type", Rec."Document Type);

                       SalesH.Setfilter("No.",'<>%1',Rec."No.");

                       SalesH.SetRange("External Document No.", Rec.External Document No.);

                       if SalesH.findfirst then begin

                          Error('External Document No. %1 already used in document %2',Rec.External Document No.,SalesH."No.");

    Please fix if there are any compilation issues as I just typed the logic here.

  • Suggested answer
    Mohana Yadav Profile Picture
    61,248 Super User 2026 Season 2 on at

    Make sure that once you posted the Order fully then the Order will be deleted and in that case the system will check External Doc No. in the existing Orders and not the already posted (deleted) orders.

    If you want to check all existing and previous orders then use Customer Ledger Entries.

  • KasparsSemjonovs Profile Picture
    4,851 Super User 2026 Season 1 on at

    This is done already on Purchase Orders, so You can check the validation of that field, and create the same for Sales Documents.

  • DAnny3211 Profile Picture
    11,423 Super User 2026 Season 1 on at

    hi

    the external document number is not unique, you can associate it with multiple orders

    so the solution that Mohana proposes is correct

    DAniele

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 720 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 436 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 409 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans