Announcements
No record found.
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?
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.
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.
Testfield is the correct function to use if you want to check if an field is empty.
Thank you!
You can use
ShowMandatory = true;
Importance = Promoted;
Thank you.
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.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
OussamaSabbouh 2,161 Super User 2026 Season 1
YUN ZHU 1,046 Super User 2026 Season 1
Dhiren Nagar 932 Super User 2026 Season 1