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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Show form control as mandatory red box for enum field value in D365

(0) ShareShare
ReportReport
Posted on by 65

Hello team,

I was trying to display the enum filed in form as mandatory filed.(red color with * symbol) in D265

here issue is like, ever time when i click new form control is initialized with enum default value, so i was not able to meet my requirement.

I have tried to remove the label for 0th value and made table field as mandatory also, form is showing blank value on the control but it is taking 0 for default value in database

and not throwing the mandatory warning for the control.

How can i achieve this?

Thanks in advance for help

I have the same question (0)
  • Suggested answer
    vinitgoyal2005 Profile Picture
    6,332 on at

    Hi Chaitanya raj,

    You can add validation on ValidateField/ValidateWrite method and throw an error instead of trying to make it mandatory.

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Chaitanya,

    Enum fields will always default with a value.

    You will need to write code in validateWrite in form datasource or in table (if it is a table field) to throw an error if any value other than the default value is not selected.

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Chaitanya,

    I think mandatory check will only work if you don't have "zero" element (EnumValue = 0) at all in enum and enum should be non-extensible (Is Extensible property = False)

  • Chaitanya raj Profile Picture
    65 on at

    I have not added zeroth element in the enum, i have made all my enum values will start from element value - '1'. and made isExtensible -  false

    After this it is behaving like mandatory field, but in form control is not looking like mandatory(i mean its not displaying as a red colored box).

    Anything i am missing here?

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Chaitanya,

    The red-colored box is not displayed if you have a focus on the control. Could it be the issue in your case?

  • Chaitanya raj Profile Picture
    65 on at

    No Sergei,

    I have clicked on new, all other mandatory fields are displaying in red colored boxes but not this enum field.

    I have not focus on the control.

    Thanks for the response.

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Chaitanya,

    Quickly tried to test it and here are my results. The enum field is marked as mandatory on the table.

    pastedimage1597681740596v2.png

    pastedimage1597681646909v1.png

  • Blue Wang Profile Picture
    on at

    Hi Chaitanya raj,

    Remove the 0 element value, or set the 0 element value to None, so that it is applied to the field, and then the form will display blank.

    21602.PNG

    67204.PNG3443.PNG

    Get information from this blog: https://community.dynamics.com/365/financeandoperations/b/dynamicsaxhints/posts/how-to-make-enum-a-mandatory-field-on-a-table

  • kevinydc Profile Picture
    10 on at

    Hi Blue,

    it's failed on 10.0.12 and later versions.

    Thanks,

    Kevin

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 456 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans