Search code examples
axaptax++dynamics-ax-2012-r3

Dynamics AX 2012: How can I get, by code, a list of all the methods within a specific form?


Is there any way for me to get, by code, a list of all the methods in a given form in Dynamics AX 2012?

I am working in developing a small tool that will insert some comments in all of the methods of custom objects through using the Editor class. However, to do so, I need the full path of each method (ex: \Classes\MyClass\CustomMethod), but I simply can't find any way to get this working for Forms.

Thanks in advance!


Solution

  • Thanks for sending me suggestions. I actually just finished writing some code to get me the information. Here is the code, for anyone who may be interested:

    //I used the BatchJobHistory form as a test, since I called this static method from a job
    public static void findAllChildNodes(str _nodeName = "\\Forms\\BatchJobHistory", boolean _isMethod = NoYes::No)
    {
        TreeNode         treeNode;
        TreeNodeIterator treeNodeIterator;
        treeNode         methodsNode;
        str              treePath;
        boolean          containsMethod;
    
        treeNode = TreeNode::findNode(_nodeName);
        treeNodeIterator = treeNode.AOTiterator();
        methodsNode = treeNodeIterator.next();
    
        while(methodsNode)
        {
            treePath = methodsNode.treeNodePath();
            containsMethod = strScan(treePath, 'Methods', 1, strLen(treePath));
    
            if (methodsNode.AOTchildNodeCount())
            {
                //TestClass is the class containing this method
                TestClass::findAllChildNodes(treePath, containsMethod);
            }
            else if (_isMethod)
            {
                info(strFmt("%1", treePath));
            }
    
            methodsNode = treeNodeIterator.next();
        }
    }