Skip to main content

Notifications

Community site session details

Community site session details

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

How I can prevent inserting duplicate values in External Document Number on page "Posted Sales Inv. - Update"??

(0) ShareShare
ReportReport
Posted on by 37

Hello Experts,

I need someone to help me with how I can prevent inserting duplicate values in external document numbers on the page "Posted Sales Inv. - Update".

6013.Screenshot-_2800_124_2900_.png

  • Lama Profile Picture
    37 on at
    RE: How I can prevent inserting duplicate values in External Document Number on page "Posted Sales Inv. - Update"??

    Thank you very much for your time and your help Mr. Mohana.

  • Suggested answer
    Mohana Yadav Profile Picture
    60,222 Super User 2025 Season 1 on at
    RE: How I can prevent inserting duplicate values in External Document Number on page "Posted Sales Inv. - Update"??

    try this

    https://youtu.be/NwYCMDqW-Bk

  • Lama Profile Picture
    37 on at
    RE: How I can prevent inserting duplicate values in External Document Number on page "Posted Sales Inv. - Update"??

    Your answer is always short and useful. Thank you for your support Mr.ZHU

    I benefited greatly from the link you provided 

    https://yzhums.com/24923/

  • Verified answer
    YUN ZHU Profile Picture
    81,780 Super User 2025 Season 1 on at
    RE: How I can prevent inserting duplicate values in External Document Number on page "Posted Sales Inv. - Update"??

    Hi, I checked this page, there is no "External Document No." field in the standard, did you customize it?

    When customizing this page, in addition to adding new fields, there are still points that need attention. I hope the following information can give you some tips.

    https://yzhums.com/24923/

    pastedimage1676596793526v1.png

    For validation checks, you can look at the code below.

    pageextension 50116 MyExtension extends "Posted Sales Inv. - Update"
    {
        layout
        {
            addafter("No.")
            {
                field("External Document No."; Rec."External Document No.")
                {
                    ApplicationArea = All;
    
                    trigger OnValidate()
                    var
                        SalesInvHeader: Record "Sales Invoice Header";
                    begin
                        SalesInvHeader.Reset();
                        SalesInvHeader.SetRange("External Document No.",Rec."External Document No.");
                        if not SalesInvHeader.IsEmpty then
                        Error('Duplicate values in External Document Number');
                    end;
                }
            }
        }
    }

    Thanks

    ZHU

  • Lama Profile Picture
    37 on at
    RE: How I can prevent inserting duplicate values in External Document Number on page "Posted Sales Inv. - Update"??

    Thanks for your help, Mr. Mohana.

    I solved this problem by  "OnValidate trigger " as you advised me.

  • Suggested answer
    Mohana Yadav Profile Picture
    60,222 Super User 2025 Season 1 on at
    RE: How I can prevent inserting duplicate values in External Document Number on page "Posted Sales Inv. - Update"??

    You can start with learning AL from the below link

    learn.microsoft.com/.../devenv-get-started

    You have to write code on OnValidate trigger of the External Document No. field and check if that value is present in Sales Invoice Header's external document no. field except the current document.

    Maybe you can start implementing the logic and ask us if you are facing any issues.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,996 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans