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

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,613 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
    100,212 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,948 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 936 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 616 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans