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

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,172 Super User 2026 Season 1 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,161 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
    97,970 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,161 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,046 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 932 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans