Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

I need to do External Document No. as mandatory.

Posted on by 186

Here when we going to insert lines in sales order without giving the value to the External Document No. then the External Document No. must show the error.

SalesLinesInsertion.PNG

  • Verified answer
    tanya07 Profile Picture
    tanya07 1,554 on at
    RE: I need to do External Document No. as mandatory.

    Hi,

    To top Teddy's reply, Please follow the same 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
    YUN ZHU 73,698 Super User 2024 Season 2 on at
    RE: I need to do External Document No. as mandatory.

    Hi, For External Document No., please use the settings suggested by Josh. In the BC Demo database, Purchase Document is automatically enabled this, but for Sales Document, it is not enabled by default, so you may not notice it.

    For the customization of field mandatory, I hope the link below can give you some new inspiration.

    https://yzhums.com/4940/

    Thanks.

    ZHU

  • Verified answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 17,965 Super User 2024 Season 2 on at
    RE: I need to do External Document No. as mandatory.

    Agree with Teddy H.

    Additionally if you have to write this code (assuming you have to) then you should write on table OnBeforeInsert event.

  • Suggested answer
    Dallefeld Profile Picture
    Dallefeld 11,425 User Group Leader on at
    RE: I need to do External Document No. as mandatory.

    Agree with Teddy H.

    Trying to force data entry errors are hard, if the user does not access the field, there is no test that happens. Release is the best place to test for errors.

    If your reason for the change is that you want the external document number on the lines, then your code at Release could validate that you have an external document number and if the lines are blank, it can populate the value.

  • Verified answer
    TeddyH Profile Picture
    TeddyH 12,868 Super User 2024 Season 1 on at
    RE: I need to do External Document No. as mandatory.

    Rather than putting it on page extension, why not put it on Codeunit 414 - Release Sales Document ?

    You can subscribe to event OnBeforeReleaseSalesDoc and put the TestField there.

    Yes, users can insert the line, but they will not be able to post or release the order without filling in External Document No.

  • RE: I need to do External Document No. as mandatory.

    Thanks for the reply. but it is only useful for the showing mandatory symbol. But my requirement is not that one. please check my description.

  • Suggested answer
    JAngle Profile Picture
    JAngle 33,159 on at
    RE: I need to do External Document No. as mandatory.

    Fairly sure testfield doesn’t require that as the if statement because it is testing for a value - which in this case has to be any text value.

    Could you not use standard setup here and save on development effort?

    1950BB32_2D00_2C7E_2D00_48DD_2D00_A2D8_2D00_8DED73258FEB.jpeg

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans