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

Setting BC Field to Mandatory

(7) ShareShare
ReportReport
Posted on by 683
On the Sales Order page, I have configured the "External Reference No." field as Mandatory, and have also created the following trigger to not let the user close the page unless a value is entered:
 
    trigger OnQueryClosePage(CloseAction: Action): Boolean
    begin
        Rec.TestField("External Document No.");
    end;
 
My question is, I have also changed the field Caption to be "Customer Purchase Order No.", and want the message to indicate that Caption instead of what appears below.
 
Can this be accomplished somehow?
I have the same question (0)
  • Suggested answer
    ME-31032107-0 Profile Picture
    683 on at
    I wound up doing it this way, but not sure if there is a better method.
     
        trigger OnQueryClosePage(CloseAction: Action): Boolean
        var
            OrderNo: Text;
            ErrorMsg: Label 'Customer Purchase Order No. is required for Sales Order \ %1.';
        begin
            OrderNo := Rec."No.";
            if Rec."External Document No." = '' then begin
                Error(ErrorMsg, OrderNo)
            end;
        end;
  • Verified answer
    YUN ZHU Profile Picture
    95,307 Super User 2025 Season 2 on at
    You just need to update the caption of the table first. The error message of this method is to take the caption of the table field.
    For example,
     
    In addition, this is a standard feature and does not require customization.
    Dynamics 365 Business Central: Set External Document No./Vendor Invoice No. as mandatory (Ext. Doc. No. Mandatory)
     
    Thanks.
    ZHU
  • ME-31032107-0 Profile Picture
    683 on at
     
    Thanks for the tip on the tableextension Caption (hard to believe I missed that), and the Sales & Receivables setup.  While the S&R setup screen option does set the field as Mandatory, it does not prevent the user from exiting the screen w/out entering a value.  So, I need the additional code to prevent that.
  • Suggested answer
    RockwithNav Profile Picture
    8,576 Super User 2025 Season 2 on at
    Instead of TESTFIELD you can write this - 
     
    IF "External Reference No." = ' ' then
        Error('%1 is required.', FieldCaption("External Reference No."));

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 3,175

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,476 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,435 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans