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 :
Microsoft Dynamics AX (Archived)

how to get enum name from enum value????????

(0) ShareShare
ReportReport
Posted on by 327

hai all i need one help.i have a data in excel sheet in that sheet one feild is gender.

but it storing data like 0,1  which means 

0=male

1=female

so i want to import that in my table so i need to convert that 0 as male and i need to store in table.how to pass that enum value and how to get enum name pls help me

thanks in advance............

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Hi karthik143,

    You need to have an Enum  with two elements : Male = 0, Female = 1. AX stores enums as integers in DB so when you assign 0 or 1 to you field AX automatically converts it to enum and show enum instead of integer everywhere.

    So you can write eihter MyTable.MyField = NoYes::Yes or MyTable.MyField = 1, result would be the same.

  • karthik143 Profile Picture
    327 on at

    thanks for replay ievgen Miroshnikov...

    but i have a little confusion.forgot about excel.i have written a simple job.

    NoYesBlank a;

       int b;

      b=Global::enum2int(NoYesBlank::Yes);

      info(strFmt("%1",b))

    i am passing YES as a enum and i am getting enum value is 1

    instead of "yes" i need to pass 1 and my output would be YES, is it possible are not if possible means may i know that conversion function....

  • Verified answer
    ARPIT CHAVHAN Profile Picture
    4,359 on at

    Hi Karthik,

    Use sysdictenum class to get the name of the enum value.

    Please go through the link below. This will definitely resolve your issue.

    www.coolitguys.com/.../how-to-get-the-name-not-label-of-an-enum-value-in-ax3

  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

    An enum type is just a list of named integer values. For example, if you save NoYesBlank::Yes to database, you won't ever see Yes in database - you will find number 1 there.

    To convert the number to the enum, you just need an assignment:

    NoYesBlank myVariable = 1;

    If you need something else, please explain your requirement in detail.

  • karthik143 Profile Picture
    327 on at

    thank you ARPIT CHAVHAN its working fine

  • ARPIT CHAVHAN Profile Picture
    4,359 on at

    your welcome.

  • Suggested answer
    Community Member Profile Picture
    on at

    Press Ctrl+D, Go to Data Dictionary > go to Base Enums tab > open and Type field name and check the value in properties in right hand side

  • Suggested answer
    Prasanna Munasinghe Profile Picture
    35 on at

    static int enum2ArrIdx(enumId _enumId, str _value)

    {

       // Return array index when baseenum element indexes are skipping numbers.

       DictEnum dictEnum;

       int i, ret;

       ;

       dictEnum = new DictEnum(_enumId);

       for (i = 0; i < dictEnum.values(); i++)

       {

           info (dictEnum.index2Symbol(i));

           if (dictEnum.index2Symbol(i) == _value)

           {

               ret = dictEnum.symbol2Value(dictEnum.index2Symbol(i));

               break;

           }

       }

       return ret;

    }

    //////////////////////////////////////////////

       HOLSTLTransferCategory  holSTLTransferCategory;

       int i;

       ;

       //>>>>> elements

       //Blank

       //StockLotToStockLotWH

       //ExternalSLToInternalSL

       //InternalSLToInternalCentralSL

       //InternalCentralSLToExternalSL

       i = HOLGlobal::enum2ArrIdx(enumnum(holSTLTransferCategory), 'InternalCentralSLToExternalSL');

       info (int2str(i));

  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

    Prasanna, your code doesn't answer the question ("how to get enum name from enum value?"). It does the opposite.

    By the way, please always use Insert > Code (in the rich formatting view) to paste source code.

    And note that your enum2ArrIdx() method isn't needed at all, because the same thing can be done with SysDictEnum.symbol2Value():

    int i = new SysDictEnum(enumNum(holSTLTransferCategory)).symbol2Value('InternalCentralSLToExternalSL');

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans