Wednesday, November 27, 2019

Enum extensions case in D365

Added two new values to an enum in the same model but in two different extensions.

The first one is looped perfectly (see code snippet below), and nothing but an index for the second. However, its value is present in a combobox.

final public class CDPSysPolicyParametersForm_9180_Extension
    public void populateTree()
        DictEnum          policyRuleTypeEnum;
        int               i;
        policyRuleTypeEnum = new DictEnum(enumNum(SysPolicyRuleTypeEnum));

        for(i = 0; i < policyRuleTypeEnum.values(); i++)
            str sym = policyRuleTypeEnum.value2Symbol(i);
            info(strFmt("%1 %2 %3", i, policyRuleTypeEnum.value2Name(i), sym));

        next populateTree();
Already built and syncrhonized the whole world. What else can it be?

Take a look from the SQL side.

There are some old values that I created before but deleted later. All of them are still there.

I had to delete these unsynced values manually from SQL, then added needed values in AOT, and synched DB.

In fact, DB sync is triggered if you have some changes in tables/views only.
Now it is correctly recreated.

BTW there are two good articles about the subject

 1) Extensible enums: Breaking change for .NET libraries that you need to be aware of
 2) Development tutorial: Extensible base enumerations in Microsoft Dynamics AX 7

No comments: