Skip to main content

Notifications

Business Central forum
Answered

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

Posted on by 30

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

Categories:
  • Lama Profile Picture
    Lama 30 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
    Mohana Yadav 45,274 Super User 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
    Lama 30 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
    YUN ZHU 61,112 Super User 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
    Lama 30 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
    Mohana Yadav 45,274 Super User 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.

Helpful resources

Quick Links

Contextual content recommendations & SharePoint Q&A

Instantly access relevant sales materials…

Beyond the DRA Cloud Label Printing

Explore cloud-based label printing within Dynamics 365…

HR Infrastructure Customer merge

Important considerations for HR Customer migrations…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,418 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,631 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,142

Featured topics

Product updates

Dynamics 365 release plans