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

Setting BC Field to Mandatory

(7) ShareShare
ReportReport
Posted on by 741
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
    741 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
    98,066 Super User 2026 Season 1 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
    741 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,848 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,032 Super User 2026 Season 1

#2
Dhiren Nagar Profile Picture

Dhiren Nagar 1,049 Super User 2026 Season 1

#3
YUN ZHU Profile Picture

YUN ZHU 1,029 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans