Friday, February 22, 2019

Enum String functions AX 2012

Enum to String conversion using label values.

str dtGetZeroValueReasonCode()
{
    DictEnum        dictEnum;
    int             valueIndex;
    int             enumId;
    str             labelId; 
    str             reasonCode;
    ;

    enumId      = enumNum(rdZeroWeightReasonCode);
    dictEnum    = new DictEnum(enumId);

    if (dictEnum)
    {
        for (valueIndex = 0 ; valueIndex < dictEnum.values(); valueIndex++)
        {         
            labelId = dictEnum.index2LabelId(valueIndex);
            reasonCode += strFmt('%1;',SysLabel::labelId2String(labelId) ? SysLabel::labelId2String(labelId) : dictEnum.index2Label(valueIndex));
        }
    }

    // Remove the trailing ";" if it exist
    if (reasonCode != "")
    {
        reasonCode = strDel(reasonCode,strLen(reasonCode),1);
    } 

    return reasonCode;
}

retrieve enum name from string

zeroWeightReasonCodeStr = zeroWeightReasonCodeElement.innerText();
zeroWeightReasonCode = str2Enum(zeroWeightReasonCode, zeroWeightReasonCodeStr);

No comments:

Post a Comment

Happening

Upgrade from AX 2012 to Latest Dynamics 365 Finance and Operation

Below are the steps defined by sequence. 1. Create new Upgrade project in Dynamics LCS. 2. Create VSTS Project and connect it with L...

Trending now