RSS

List all the Base Enumerations in AX 2012

19 Aug

Today i got a requirement to traverse and list down all enumerations available in AOT. I also needed the list of all Base Enums elements with their label & value. The result was a simple but powerful script which will traverse all nodes of a Base enumerations to find all enumerations elements.

The below code will populate the list of of Base enumerations under AOT node.
static void Job_ListBaseEnumObjects(Args _args)
{
// #AOT is defined in the AOT under Macros.
#AOT
TreeNode treeNode;
EnumId enumId;
Counter counter;
SysDictEnum sysDictEnum;
BaseEnumList baseEnumList;
;

treeNode = TreeNode::findNode(#BaseEnumsPath);
treeNode = treeNode.AOTfirstChild();
while(treeNode)
{
sysDictEnum = new SysDictEnum(enumName2Id(treeNode.treeNodeName()));
baseEnumList.clear();
baseEnumList.BaseEnumID = enumName2Id(treeNode.treeNodeName());
baseEnumList.BaseEnumName = treeNode.treeNodeName();
baseEnumList.ElementCount = int2str(SysDictEnum.values());
baseEnumList.insert();
for (counter=0;counter<SysDictEnum.values();counter++)
{
baseEnumList.clear();
baseEnumList.BaseEnumID = enumName2Id(treeNode.treeNodeName());
baseEnumList.BaseEnumName = treeNode.treeNodeName();
baseEnumList.ElementLebel = SysDictEnum.index2Label(counter);
baseEnumList.ElementValue = int2str(SysDictEnum.index2Value(counter));
baseEnumList.insert();
}
treeNode = treeNode.AOTnextSibling();
}
}

I extracted table data in excel after pressing CTRL+T on browsed table.

Base Enums

Happy Daxing 🙂

Advertisements
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: