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

Get Enum Name from Enum value (integer index value)

(0) ShareShare
ReportReport
Posted on by 89

I have one enum value: LedgerPostingType and I want to use this value and grab the same enum name value from InventAccountType. The thing is, the enum values with the same names on these two enums have different index values (i.e. InventProfit is enum value 93 on LedgerPostingType but value 8 on InventAccountType). I want to convert the enum index value of LedgerPostingType to the name value (InventProfit) and then grab this same enum from InventAccountType. See the code below for what i am trying to achieve (it doesn't compile).

{

str postingTypeForLookupName, inventAccountTypeForLookupName;

LedgerPostinType postingTypeForLookup = GeneralJournalAccountEntry.PostingType;


postingTypeForLookupName = SysDictEnum.index2Label(postingTypeForLookup);
inventAccountTypeForLookup = InventAccountType::postingTypeForLookupName;

}

Thanks in advance

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    239,031 Most Valuable Professional on at

    You forgot to create an instance of SysDictEnum. Also, I believe a better approach will be refering to the element name and not the label. You can either use index2Symbol() method of SysDictEnum class, or a global function called enum2Symbol().

    Try something like this:

    str enumSymbol = enum2Symbol(enumNum(LedgerPostinType), postingTypeForLookup);
    
    SysDictEnum inventAccountDictEnum = new SysDictEnum(enumNum(InventAccountType));
    InventAccountType inventAccountType = inventAccountDictEnum.symbol2Value(enumSymbol);

    Don't forget to handle the situation when the corresponding enum element doesn't exist.

  • tristansenk99 Profile Picture
    89 on at

    Hi Martin,

    Thank you, this is exactly what I needed.

    I appreciate your help!

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 659

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 465 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 304 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans