SBX - Search With Button

SBX - Forum Post Title

how to list the elements of the node menus?

Dynamics 365 for Finance and Operations Forum

BASMA asked a question on 10 Apr 2019 7:55 AM
My Badges

Question Status

Suggested Answer

Hi,

I want to develop a form  that display all the elements of menus :

Have you any idea,

Thanks.

Reply
Blue Wang responded on 11 Apr 2019 3:51 AM
My Badges

Hi Basma,

 

I use TreeNode to get the path of Menu and the node.

 

        Set set = new Set(Types::String);

        TreeNode  menu, menuOld;

        #Properties

        #AOT

        ;

        menu = new TreeNode();
      
        menu = TreeNode::findNode(#MenusPath).AOTfirstChild();
    
        while(menu)

        {

            if(menu.AOTname())

            {

                menuOld = menu;

                info(menu.treeNodePath());

                menu = menu.AOTfirstChild();

            }

            else

            {

                menuOld = menu;

                menu = menu.AOTnextSibling();

            }

       
            if(!menu)

            {

                menu = menuOld.AOTnextSibling();

                while(!menu)

                {

                    menu = menuOld.AOTparent();

                    menu = menu.AOTnextSibling();

                    menuOld = menuOld.AOTparent();

               }

            }

 
            set.add(menu.toString());

 
            SetEnumerator setEnumerator;

            setEnumerator = set.getEnumerator();

            str path;

            while (setEnumerator.moveNext())

            {

                path = strfmt(" %1", setEnumerator.current());

            }

            info(path);
         
        }


For TreeNode, you can refer : https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.treenode?view=netframework-4.7.2

There's a similar example. https://ronnyfch.wordpress.com/2013/09/14/how-to-get-list-of-all-menu-items-at-ax-and-the-license-on-it/

Reply
BASMA responded on 11 Apr 2019 4:12 AM
My Badges

Hi Blue Wang,

I can try your suggestion in dynamics 365?

Reply
Blue Wang responded on 11 Apr 2019 4:16 AM
My Badges

Hi Basma,

What I got was the path in AOT.

Reply

@Blue Wang, are you sure that it will work in environment without source code, like T2 or Production?

Reply
BASMA responded on 15 Apr 2019 4:37 AM
My Badges

Hi @ievgen,

Have you any idea about how to  get all the buttons from any form?

My task is get all the display menuItems from menus then get all the buttons for every display menuItem

Reply
Rahul Mohta responded on 15 Apr 2019 6:08 AM
Suggested Answer

try if this helps, originally was for AX2012

static void TreeNode_traverse(Args _args)

{

    TreeNode            treeNode, treeNodeform;

    TreeNodeIterator    iterator;

    void traverseFields(TreeNode _treeNode)

    {

        TreeNode parentNode;

        parentNode = _treeNode.AOTfindChild(‘Buttons’);

        //treeNodeform = _treeNode.AOTfirstChild();

        iterator = parentNode.AOTiterator();

        parentNode = iterator.next();

        while(parentNode)

        {

            //treeNodeform = treeNodeform.AOTfirstChild();

            parentNode = iterator.next();

        }

    }

    ;

    treeNode = TreeNode::rootNode();

    treeNode = treeNode.AOTfirstChild();

    treeNodeform = treeNode.AOTfindChild(‘Form’);

    treeNodeform = treeNodeform.AOTfirstChild();

    while(treeNodeform)

    {

        traverseFields(treeNodeform);

        treeNodeform = treeNodeform.AOTnextSibling();

    }

}

reference bineetaxblog.wordpress.com/.../code-for-traverse-between-tables-and-all-the-fields

Reply
BASMA responded on 15 Apr 2019 8:17 AM
My Badges

Hi

I use this code to get the elements of menus

 public static void main(Args _args)
    {
        Set set = new Set(Types::String);

        TreeNode  menu, menuOld,subMenu;
        str menuName,subMenuName;

        #Properties
        #AOT

        ;

        menu = new TreeNode();
      
        menu = TreeNode::findNode(#MenusPath).AOTfirstChild();
        menuName=menu.AOTname();
       
        while(menu)

        {
            subMenu=menu.AOTfirstChild();
            while(subMenu)
            {
                subMenuName =subMenu.AOTname();
                subMenu=subMenu.AOTnextSibling();
            }
            

           
        } 
    }


Normally I got "DemoDataWorkspaceGenerate" in the variable "subMenuName" But I got "Generate data".

Reply
Rahul Mohta responded on 15 Apr 2019 6:08 AM
Suggested Answer

try if this helps, originally was for AX2012

static void TreeNode_traverse(Args _args)

{

    TreeNode            treeNode, treeNodeform;

    TreeNodeIterator    iterator;

    void traverseFields(TreeNode _treeNode)

    {

        TreeNode parentNode;

        parentNode = _treeNode.AOTfindChild(‘Buttons’);

        //treeNodeform = _treeNode.AOTfirstChild();

        iterator = parentNode.AOTiterator();

        parentNode = iterator.next();

        while(parentNode)

        {

            //treeNodeform = treeNodeform.AOTfirstChild();

            parentNode = iterator.next();

        }

    }

    ;

    treeNode = TreeNode::rootNode();

    treeNode = treeNode.AOTfirstChild();

    treeNodeform = treeNode.AOTfindChild(‘Form’);

    treeNodeform = treeNodeform.AOTfirstChild();

    while(treeNodeform)

    {

        traverseFields(treeNodeform);

        treeNodeform = treeNodeform.AOTnextSibling();

    }

}

reference bineetaxblog.wordpress.com/.../code-for-traverse-between-tables-and-all-the-fields

Reply

SBX - Two Col Forum

SBX - Migrated JS