Notifications
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
OussamaSabbouh 2,917
Jainam M. Kothari 1,161 Super User 2025 Season 2
YUN ZHU 1,025 Super User 2025 Season 2