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

Mandatory fields AL

(0) ShareShare
ReportReport
Posted on by

Dear All,

How can I have the location field mandatory on the Purchase Order line after/when I open a purchase order?.

Which page trigger is the best suited for this?.

  • Anita75 Profile Picture
    1,165 on at

    Not sure why you need a trigger on open page ..I'd validate when a user enters a line say when Qty/price entered  using OnAfterCalcLineAmount as below code unit:

    begin

           if PurchaseLine.Type = PurchaseLine.Type::Item then begin

               If (PurchaseLine."Location Code" = '') then begin

                   if PurchaseLine.FindFirst() then

                       error('Must have location code');

               end;

           end;

       end;

  • Verified answer
    Jack Davies Profile Picture
    120 on at

    Add a page extension...

    pageextension xxxxx "My PO Subform" extends "Purchase Order Subform"

    {

       layout

       {

           modify("Location Code") { ShowMandatory = true; }

       }

    }

    This will show the location as being mandatory on the lines (the red * will be displayed in the empty field)

  • Neil Phelan Profile Picture
    161 on at

    Jack just following up on this old thread.

    While I can show the field as mandatory it doesn't stop the user from not entering a value in the field. Is there any way to force the users to enter a value before the record can be saved?

  • Jack Davies Profile Picture
    120 on at

    You would need the OnQueryClosePageEvent...

    That would give you results similar to the this ... https://drive.google.com/file/d/1D_I8ImbYItqWCbD0IlzEeqbMYztoBKQe/view?usp=sharing (this is a "programming without code" solution that is available for BC v18+)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 624 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 440 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 244 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans