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

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?.

I have the same question (0)
  • 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

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

#2
YUN ZHU Profile Picture

YUN ZHU 931 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans