For diagnostics purposes it is often useful to search the AOT for all objects matching cetain properties. For example you may want to find all display menutitems that are pointing to a specific form. The below job illustrates how to simply traverse the Display Menuitems node in the AOT to locate all items who’s “ObjectType” is “Form” and object is a specific form name. E.G. “PurchReqTable”.
static void FindMenuItemsForForm(Args _args) { #AOT str find = "PurchReqTable"; TreeNode root = TreeNode::findNode(#MenuItemsDisplayPath); TreeNode current; TreeNodeTraverser trav = new TreeNodeTraverser(root,false); current = trav.next(); while (current) { if ((current.AOTgetProperty('ObjectType') == "Form") && (current.AOTgetProperty('Object') == find)) info(strFmt("Found menuitem %1",current.AOTname())); current = trav.next(); }
Adapting this to search other nodes is as simple as changing the original node instantiation to search a different path as well as changing the AOTgetProperty() method to search through the properties relevant to you.
Happy Daxing
Original community post: https://community.dynamics.com/ax/f/33/p/161258/387257#387257