Wednesday, August 19, 2020

Convert EnumName to Label in AX2012 / D365 Finance & Operations

 Hi DaxPeople,

Today we are going to look into the most common issue we face while using Enums and its conversions.

In this post, we are talking about the code which will convert an EnumName to Label.


//SysDictEnum is the class to access all the conversion functions related to Enum

SysDictEnum  dictEnum       = new SysDictEnum(enumNum(SalesStatus));

str enumName      = 'Backorder';

int enumValue;


//symbol2Value gives us the "Value" available for that EnumName- Backorder         

enumValue     = dictEnum.symbol2Value(enumName);

//value2Label will gives us the label available for that particular enum - In this case its Open Order

enumLabel     = dictEnum.value2Label(enumValue);

       

Info(strFmt('enum Value - %1, enum label - %2',enumValue, enumLabel));


Hope the above code helps for your Enum conversion.


Happy Daxing..!!


No comments:

Post a Comment