Using X++ code find out Enum type data complete infomation

时间:2021-09-27 19:17:42

Look up Enum type data complete infomation with Jobs.

Such as : Index,Name,EnumValue,Label,ConfigurationKey....

Remark by Jimmy August 03th 2010

 

static void Jimmy_EnumLookupDialog(Args _args)
{
    Dialog                  dlg         = new Dialog("Please selected Enum name!");
    DialogField             dlgLanguage = dlg.addField(typeid(LanguageId));
    DialogField             dlgEnumId   = dlg.addField(typeid(EnumDataTypeName));//UtilElementType - 41

    DictEnum                dictEnum;
    LanguageId              languageId;
    int                     valueIndex,enumId;//UtilElementType
    Str                     labelId,enumName;
;
    dlgLanguage.value("zh-hans");
    dlgEnumId.value("UtilElementType");

    dlg.doInit();
    if(!dlg.run())
        return;

    languageId  = dlgLanguage.value();
    enumName    = dlgEnumId.value();

    enumId      = global::enumName2Id(enumName);
    dictEnum    = new DictEnum(enumId);
    setprefix(enumName + " - " + languageId);
    if (dictEnum)
    {
        for (valueIndex = 0 ; valueIndex <= dictEnum.values(); valueIndex++)
        {
            labelId = dictEnum.index2LabelId(valueIndex);
            info(Strfmt("[EnumValue] %1 - [Name] %2 - [Label] %3 - [Curreny Label] %4 - [Index] - %5",
                        dictEnum.index2Value(valueIndex),
                        dictEnum.index2Symbol(valueIndex),
                        dictEnum.value2Name(valueIndex),
                        SysLabel::labelId2String2(labelId, languageId),
                        valueIndex
                        ));
        }
    }
}