web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

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 760
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
    760 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
    102,049 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
    760 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
    9,191 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,687 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,041 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 974 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans