Skip to main content

Notifications

Announcements

No record found.

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

Add Field which is mandatory for posting

Posted on by 15

I want to add a field in a sales order that is mandatory when posting it. It should only be allow to post if the field is not empty. Solutions like ShowMandatory or NotBlank are not an option.
I think I need a CodeUnit for that - or is there another way?

  • YUN ZHU Profile Picture
    YUN ZHU 73,698 Super User 2024 Season 2 on at
    RE: Add Field which is mandatory for posting

    Hi, just to add some info.

    Dynamics 365 Business Central: How to make a field mandatory

    https://yzhums.com/4940/

    Hope this helps as well.

    Thanks.

    ZHU

  • Shrey Chauhan Profile Picture
    Shrey Chauhan 288 on at
    RE: Add Field which is mandatory for posting

    You can use

    ShowMandatory = true;

    Importance = Promoted;

    Thank you.

  • fherrscher Profile Picture
    fherrscher 15 on at
    RE: Add Field which is mandatory for posting

    Thank you!

  • Suggested answer
    fherrscher Profile Picture
    fherrscher 15 on at
    RE: Add Field which is mandatory for posting

    Thank you!

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Add Field which is mandatory for posting

    Testfield is the correct function to use if you want to check if an field is empty.

  • Verified answer
    Deekshitha Reddy Profile Picture
    Deekshitha Reddy 219 on at
    RE: Add Field which is mandatory for posting

    You can try this....

    IF Rec."field Name"=' ' THEN// Single Quotation Marks without space.

     ERROR('Enter  value for the field ');

    else

    ...

      //code when the field is not empty.

    ;

    Add the above code in trigger OnAction of Post button.

    Hope this helps.

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Add Field which is mandatory for posting

    You need a codeunit to subscribe to the event OnBeforePostSalesDoc of Codeunit 80 Sales-Post

    add your condition to check whether the field is filled or not and throw error if not.

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