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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

External Document Number in Sales Order

(0) ShareShare
ReportReport
Posted on by 130

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;
I have the same question (0)
  • Suggested answer
    MahGah Profile Picture
    15,529 on at

    Hi

    Please see suggestions in this post

    community.dynamics.com/.../i-need-to-do-external-document-no-as-mandatory

  • Suggested answer
    tanya07 Profile Picture
    1,638 on at

    Hi,

    Please follow as below -

    [EventSubscriber(ObjectType::Codeunit, 414, 'OnBeforeReleaseSalesDoc', '', false, false)]

       local procedure MyProcedure(var SalesHeader: Record "Sales Header")

       begin

           SalesHeader.TestField(ExtDocNo);

       end;

    Thanks,

    Tanya Kharbanda

    Don't forget to help the community by verifying the answer if your question has been answered. It will let others know that the topic has a verified answer.

  • Verified answer
    YUN ZHU Profile Picture
    95,748 Super User 2025 Season 2 on at

    Hi, please try the following.

    pastedimage1651709828057v1.png

    tableextension 50109 MyExtension extends "Sales Line"
    {
        trigger OnBeforeInsert()
        var
            SalesHeader: Record "Sales Header";
            Text000: Label 'The external document No. have to be given';
        begin
            if SalesHeader.Get(SalesHeader."Document Type"::Order, Rec."Document No.") then
                if SalesHeader."External Document No." = '' then
                    Error(Text000);
        end;
    }

    Thanks.

    ZHU

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,066

#2
YUN ZHU Profile Picture

YUN ZHU 658 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 595

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans