Pages

Thursday, May 18, 2017

How to programmatically add menu items to favorites menu via X++ in Dynamics AX

The favorites menu is a bit unusual in AX in the way you need to add to it. Most of the way it works appears to be Kernel level, but through some TreeNode usage you can add items to it.

This will add the "SalesTable" menu item to your favorites.


static void JobAddToFavorites(Args _args)
{
    TreeNode                treeNode;
    TreeNode                menuToAdd = TreeNode::findNode(@"\Menu Items\Display\SalesTable");
    TreeNodeIterator        iterator;
    UserMenuList            userMenu;
    Menu                    menuNode;


    treeNode = infolog.userNode();
    iterator = treeNode.AOTiterator();
    treeNode = iterator.next();
    if (treeNode)
    {
        userMenu = treeNode;

        // find 'My Favorites' user menu; 
        treeNode = userMenu.AOTfindChild("@SYS95713");

        // Note menuNode is a different object than userMenu
        menuNode = treeNode;

        menuNode.addMenuitem(menuToAdd);
    }    
}

Another table to take note of is SysPersonalization if you're looking at doing this for multiple users. I haven't dug into this deeply, but this code snippet should get you started with what you may want to do.

3 comments:

  1. Best software to make and design databases and easily can insert tables through queries. Thanks for sharing this with us and helping people with problems

    ReplyDelete
  2. Creo que ahora debes probar diferentes medios para entretenerte y, por lo tanto, debes comenzar a usar el casino. Creo que para hacértelo más fácil, intenta jugar apuestas esport en colombia en un casino que te traerá más dinero. Creo que apuesta total app para android sería genial para ti, te lo contarán todo y te dirán cómo jugar en el casino

    ReplyDelete
  3. Very nice! I really love this game and would like to write a short story about it! If you need some help and want to ask professional personal statement writing services someone how to write a homework or essay, you can ask this guys for help! Don't waste your money and time! Text them paper writer service and be happy to use! Good luck!

    ReplyDelete