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...
Suggested Answer

Issue with ShowMandatory = true Property for Enum Fields in Business Central

(6) ShareShare
ReportReport
Posted on by 12

Dear Dynamics Community,

I am currently attempting to use the page property ShowMandatory = true to mark an enum field as required on a page. While this property functions correctly for fields of type Code, it does not appear to have any effect when applied to enum fields.

Is there a known limitation regarding the use of ShowMandatory with enum field types? If so, I would greatly appreciate any suggestions or workarounds to achieve similar functionality for enum fields.

Thank you in advance for your support and guidance.

I have the same question (0)
  • Teagen Boll Profile Picture
    2,323 Super User 2026 Season 1 on at
    That might be tricky because ShowMandatory is just looking to see if a field isn't blank then displaying a red asterisk.
     
    You could try using the property NotBlank instead and it will also add the red asterisk and also validate the field. You could then try having one value be None like this:
    enum 50121 Loyalty
    {
        Extensible = true;
        
        value(0; None) { }
        value(1; Bronze) { }
        value(2; Silver) { }
        value(3; Gold)
        {
            Caption = 'Gold Customer';
        }
    }
     
    Then try using either ShowMandatory or NotBlank to see if that flags it as mandatory/validates the field.
  • Suggested answer
    Gregory Mavrogeorgis Profile Picture
    1,339 Super User 2026 Season 1 on at
    Hi,
     
    Yep—this is (kinda) a limitation. ShowMandatory only shows the red asterisk if a field can be blank. Enums always have a value (default = first member), so nothing to flag.
    Easy workaround:
    • Add a “Not set” enum value (make it the first).
    • Bind the asterisk to a boolean/expression:
    • ShowMandatory = (Rec."My Status" = Rec."My Status"::"Not set");
    • Enforce server-side so users can’t save “Not set”:
    • if Rec."My Status" = Rec."My Status"::"Not set" then
    •     Error('%1 is required.', FieldCaption("My Status"));
    Can’t change the enum? Use a page variable to drive ShowMandatory with your own logic, and keep the table validation.
     
    If you found this helpful please mark it as verified
  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,306 Super User 2026 Season 1 on at
    ShowMandatory doesn't work with Enum.
    What you can do is set the 0 caption as something like "Must select one".
     
    Then add a code somewhere to validate it, such as OnInsert or OnModify.
  • Suggested answer
    Jainam M. Kothari Profile Picture
    16,267 Super User 2026 Season 1 on at
  • Suggested answer
    Valentin Castravet Profile Picture
    32,685 Super User 2026 Season 1 on at

    It can work like this: most enum fields aren’t blank by default, so to use ShowMandatory include a blank option. Set both ShowMandatory and BlankZero on the field.

    For example, in the field below I set the enum’s value(0) caption to a single space and then set both ShowMandatory and BlankZero to true:
     
     
     
  • Suggested answer
    YUN ZHU Profile Picture
    100,629 Super User 2026 Season 1 on at
    Hi, hope the following helps.
    Dynamics 365 Business Central: The red asterisk next to a field (mandatory field???)
     
    Thanks.
    ZHU
  • Suggested answer
    OussamaSabbouh Profile Picture
    15,595 Super User 2026 Season 1 on at
    Hello,
     
    Yes — ShowMandatory doesn’t highlight enum fields because enums always have a value (their default option).
    To mimic required behavior:
     
    Add a blank/“<Select>” value in the enum.
     
    Use StyleExpr or OnValidate to flag or block when it’s still “<Select>”.
     
    Regards,
    Oussama Sabbouh
  • Suggested answer
    Aman Kakkar Profile Picture
    3,465 Super User 2026 Season 1 on at
    Hi,
     
    You can achieve this via writing below mentioned code snippets.
     
    STEP 01 - Add a blank value at index 0 in your enum definition. This allows the field to appear empty until a valid selection is made.
     
    enum 50010 Test
    {
        Extensible = true;
    
        value(0; "") { }
        value(1; Test01) { }
        value(2; Test02) { }
        value(3; Test03) { }
    }
    STEP 02 - On your page field, set the following properties:
     
    field("Test Enum"; Rec."Test Enum")
    {
        ShowMandatory = true;
        BlankZero = true;
    }
     
    Now the enum field will behave like a required field (ShowMandatory = true) — showing the red asterisk and prompting the user to select a valid value other than the blank one.
     
     
    Do mark as verified if this helps.
    Aman K
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,365 Super User 2026 Season 1 on at

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,036 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,179 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 828

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans