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, ...
Answered

BaseEnum element order

(0) ShareShare
ReportReport
Posted on by

Hi,

got a question about BaseEnum. If lets say I create New Base Enum, with element :

1. A

2. B

3. C

And after a while, I want to add, lets say "Undecided" and needs to go to number 1, but it not only to move it (by using Alt) to the top. I want the default also automatically to be that new one (1 = Undecided). How to make that happened ?

Without need to go to the table that has that BaseEnum and put some InitValue.

Because without that code, actually BaseEnum will always go to the 1st one, right, but if we change the order, the default will stayed at whatever the 1st one during BaseEnum creation only.

Thanks.

I have the same question (0)
  • Blue Wang Profile Picture
    on at

    HI Wong,

    BaseEnum starts from 0.(the first value)

    If you bind it to an enum field and apply it to the form, you can specify the default value in the init () method through code, and it will be obtained every time it is loaded. Or when you want to create records by, you can override create () etc.

  • Community Member Profile Picture
    on at

    Hi Wang,

    Yes, understand about the Init() method. That's what I said, what if I don't want to use that. Since originally, when 1st creation, we don't have to. It will get the 1st element anyway. But when we modified, it's not reflected.

  • Suggested answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    The default value of the underlying data type, integer, is zero. Therefore the default value of an enum field is the element with value zero. That's it.

    You would have to change which element has value 0 and update data in all fields based on this enum (because 0 would suddenly have different meaning).

  • Community Member Profile Picture
    on at

    Hi Martin,

    Yeah that's what I know too actually (in previous AX). But in D365, the properties no longer having "Value", or has it ?

  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Aha, you must be talking specifically about enums with Extensible=Yes. In that case, you indeed don't have control over element values.

    If it's an extensible enum, then I don't have any solution for you.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Extensible enums do also have integer value behind the curtains, but it's determined during db synchronization and can be different in different environments.

    The value of the first value is 0 according to the documentation: https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/extensibility/extensible-enums

    However I'm not sure what happens if you change the first element by rearranging the elements. Is the new default value the first element, or the one that was first before the rearrangement.

    What I do know is that you can easily test this in 5 minutes on your dev system. Then you can deploy the changes to another system to see how it behaves in deployment.

    Could you please do that and update the result here so we all can learn something new. Thanks a lot!

  • Community Member Profile Picture
    on at

    Hi Nikolaos,

    The "just add" new element is now the first element, but in all table using this BaseEnums, when we first create record, it will show the original / initial first element as default  (which is now on 2nd position in my AOT)

    and yes, it is deployed with the new element changes (new element "wants" to be the 1st) but it's not, the original so stubborn to be no 1, sadly.

    Btw, to @Martin, I forgot to mention, when you're saying "with extensible= Yes", meaning for every enum which "Extensible = Yes" when we extend then we have no control ? (if like this, I can understand). Or it is for all enums as of now (this current AX version) ?

    and also my Base enums is really created by me, it is new Base Enum. But I tried to put "Extensible = No" for test, still there is no Value property like the old days. It is kind of strange because it is my own enum, why I cannot change the element's order.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    So, this means that when you add new elements to extensible enum, the enum values of existing enum values are not changed. Which is good because then your data will keep working as before when you apply your update to test/prod. You can of course change the default value by initializing it in code (initValue() method of table).

    About not seeing the numeric value of non-extensible enum, don't forget to set property "Use enum value" to Yes. 

  • Community Member Profile Picture
    on at

    Yes, it is true for that reason, only this a new BaseEnums which still in Development environment. So I guess the only way to have the correct order and the default without touching initValue method, is to delete that BaseEnum and create it again.

    Because that is my initial question, how without code in initValue. 

    Btw, set property "Use enum value" to Yes. This is the BaseEnum property ? I didn't see it.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    I would actually assume that when you deploy the enum to test system, the first value in the list would end up as the default value. You can test this, too, if you want to.

    But since it's still in dev-phase and not deployed anywhere, simply delete it.

    When developing enums it's always good to think about the default value already in the beginning.

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
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans