values of base enums using code in x++

 

AX / D365FO – How to get static void getEnumValues(Args _args)

{
    EnumId   enumId   = enumNum(LedgerDimensionType); //Put here your enum
    DictEnum dictEnum = new DictEnum(enumId);
    int      numOfValues  = dictEnum.values(); //This method gets the total number of enum values
    int      counter; 

    for(counter = 0; counter < numOfValues; counter ++)
    {
       //You can use the number of method exposed by DictEnum class
       Info(strFmt('%1',dictEnum.index2Value(counter)));
       Info(strFmt('%1',dictEnum.index2Symbol(counter)));
       Info(strFmt('%1',dictEnum.index2Label(counter)));
    }
}

Comments