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

Add Field which is mandatory for posting

(0) ShareShare
ReportReport
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?

I have the same question (0)
  • Verified answer
    Mohana Yadav Profile Picture
    61,001 Super User 2025 Season 2 on at

    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.

  • Verified answer
    Deekshitha Reddy Profile Picture
    219 on at

    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.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at

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

  • Suggested answer
    fherrscher Profile Picture
    15 on at

    Thank you!

  • fherrscher Profile Picture
    15 on at

    Thank you!

  • Shrey Chauhan Profile Picture
    284 on at

    You can use

    ShowMandatory = true;

    Importance = Promoted;

    Thank you.

  • YUN ZHU Profile Picture
    95,597 Super User 2025 Season 2 on at

    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

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,917

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,161 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,025 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans