Want to Traverse AOT\Menu in Ax2012

Hi Team.

I want to Traverse my AOT\Menu

in Ax2012 .Am using TreeNode And Treenode traverse…

BUt it is working only for my first child element.

Let me know how i can do for All child element.

Treenode.next() is not working…

Suggestions are welcome…



You did something wrong in your code (which you didn’t show). Try this example:

TreeNode root = TreeNode::findNode(@'\Menus\Home');
TreeNodeTraverser traverser = new TreeNodeTraverser(root);
TreeNode node;
while (traverser.next())
    node = traverser.currentNode();

Thanks Martin,

Working For Me…

Superb !!!

Dear Manas,

Don’t forget to verify the solution, it helps others to refer :slight_smile:


Hi Kiran, I was Busy in some Different issues… Check my code… I need to modify it little more.As node has to traverse in My way as i want. But this code will help to all it seems… static void Manas_Treenodetraverse(Args _args) { TreeNode treeNode, treeNodeTable; TreeNodeTraverser T1; TreeNodeIterator iterator; str _Nodevalue,_Nodevalue1; MenuItem _Menu; MenuItemName MenuItemName; void traverseFields(TreeNode _treeNode) { TreeNode parentNode; t1 = new TreeNodeTraverser(_treeNode); parentNode =T1.next(); iterator = parentNode.AOTiterator(); parentNode = iterator.next(); while(parentNode) { t1 = new TreeNodeTraverser(parentNode); parentNode =T1.next(); iterator = parentNode.AOTiterator(); //MenuItemName=“AccountantElectronicAddressEdit_BR”; // info(strFmt("%1",parentNode.treeNodePath())); _Nodevalue1=“MenuItemType”; _Nodevalue=parentNode.AOTgetProperties(false,false,false); if(strContains(_Nodevalue,_Nodevalue1)==true) { if(parentNode.AOTgetProperty(“Menuitemname”)) { info(parentNode.AOTgetProperty(“Menuitemname”)); info(strFmt("%1",parentNode.treeNodePath())); } } parentNode = iterator.next(); } } ; treeNode = TreeNode::rootNode(); treeNodeTable = treeNode.AOTfindChild(‘Menus’); treeNodeTable = treeNodeTable.AOTfindChild(‘AccountsPayable’); while(treeNodeTable) { traverseFields(treeNodeTable); treeNodeTable = treeNodeTable.AOTnextSibling(); } } Thanks, Manas