X++ to get All Enums available in AOT

 In Standard we have SrsAnalysisEnums table which will store all the Enums used in Analytical services.Any in some cases it might not show all the Enums. To load the missing enums from the AOT we can use the following code.

To avoid any future confilcts you can create a custom table and load Enums in it.


class  PopulateSRSAnalysisEnumsBatch extends SysOperationServiceBase

{

     /// <summary>

    /// Class description

    /// </summary>

    /// <returns>ClassDescription</returns>

   public ClassDescription  classdescription()

   { 

       return "Load enum values in Enum master";

    

    }


    /// <summary>

    /// Load records in Enum master

    /// </summary>

    public void processRecords()

    {

        #AOT

        TreeNode treeNode;

        Custom_SRSAnalysisEnums analysisEnums;

        DictEnum currentEnum;

        str currentEnumName;

        int valueCount;

        RecordInsertList records = new RecordInsertList(tablenum(Custom_SRSAnalysisEnums));

        ttsbegin;

        treeNode = TreeNode::findNode(#BaseEnumsPath);

        treeNode = treeNode.AOTfirstChild();

        delete_from analysisEnums;

        while(treeNode)

        {

            currentEnum = new SysDictEnum(enumName2Id(treeNode.treeNodeName()));

            valueCount = currentEnum.values();

           

            for(int j = 0; j < valueCount; j++)

            {

                analysisEnums.EnumName      = currentEnum.name();

                analysisEnums.EnumItemName  = currentEnum.index2Symbol(j);

                analysisEnums.EnumItemValue = currentEnum.index2Value(j);

                analysisEnums.EnumItemLabel = currentEnum.index2Label(j);

                records.add(analysisEnums);

            }

            records.insertDatabase();


            treeNode = treeNode.AOTnextSibling();

        }

        ttscommit;


        Info("Data added for all AOT Enums in custom_SRSAnalysisEnums table");

       

    

    }


}

No comments:

Post a Comment