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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Enum values and numbers

(0) ShareShare
ReportReport
Posted on by 1,552

so i have an enum (not mine) that has the following values

Enum

A

B

C

D

E

with isExtensible true, and there is an extension to it (not mine)

in the UI i'm getting that this record has an Enum B, but in SQL database i'm getting 0. shouldn't 0 be A not B so how come? this happens to several values 

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Enum values and numbers

    Hi junior AX,

    Which enum are you working with?

  • junior AX Profile Picture
    1,552 on at
    RE: Enum values and numbers

    Hi Gunjan,

    it's a customized one

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Enum values and numbers

    Hi jumior AX,

    The values are stored in the database - ENUMIDTABLE and ENUMVALUETABLE.

    Please check this post and see the values stored for the customized enum.

  • Suggested answer
    Martin Dráb Profile Picture
    236,297 Most Valuable Professional on at
    RE: Enum values and numbers

    Enums are stored as numbers, not strings. If you look at the type in database, you'll indeed see it's not string, therefore it's impossible to store values like A and B.

    It's much more efficient for storing and querying.

  • junior AX Profile Picture
    1,552 on at
    RE: Enum values and numbers

    Hi Gunjan,

    So i should rely on the values coming from the database and not counting manually. Thank you

  • junior AX Profile Picture
    1,552 on at
    RE: Enum values and numbers

    Hi Martin,

    I mean the label was A B C D and normally A would mean 0, B would mean 1,...etc

    But in the database enum that had value B, it's integer was 0

  • Suggested answer
    Martin Dráb Profile Picture
    236,297 Most Valuable Professional on at
    RE: Enum values and numbers

    You should never try to guess the numbers by yourself. They don't have to be sequential and in case of extensible enums, the values can be different in different environments. Use enum values (such as  NoYes::Yes) in your code; don't refer to the underlying numbers.

  • junior AX Profile Picture
    1,552 on at
    RE: Enum values and numbers

    Hi Martin,

    If the enum was not Extensible then it will be sequential?

    because once i had to put a range on a data entity datasource like this:

    (((Status == 10) && (Filed1 == "")) || (Status == 15))

    i was forced to use enum numbers because there is another field in the range as you can see. But this status enum was not extensible. So the value won't be different in other environments right?

  • Verified answer
    Martin Dráb Profile Picture
    236,297 Most Valuable Professional on at
    RE: Enum values and numbers

    No, the fact that they don't have to be sequential applies to all ernums. Only the other statement (the values can be different in different environments) is specific to extensible enums.

    If I was you, I would create a boolean computed column wrapping this logic, which would be trivial to filter by - and your problem would disappear.

  • junior AX Profile Picture
    1,552 on at
    RE: Enum values and numbers

    Hi Martin,

    1. So you mean if it was extensible and in the dev environment i put this condition

    (((Status == 10) && (Filed1 == "")) || (Status == 15))

    and if it was then moved to UAT, then Status ==10 might mean something other than the one in DEV?

    But if it was not extensible, then the values will be exactly the same and there is no risk right?

    2. let's say i created a boolean computed column, how i'm going to put the range on the data entity dataSource and replace this:

    (((Status == 10) && (Filed1 == "")) || (Status == 15))

    with the boolean value of the computed column?

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,167

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 617 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans