web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / How to get AOT Objects
Finance forum

How to get AOT Objects

(0) ShareShare
ReportReport
Posted on by 336

Hi All,

I have a technical question,

Actually i'm working on a new D365 FO project, and i have a business needs, to list all AOT objects belong to a module.

in AX2012 there is a standard table: Utilelements that contains all AOT objects and their name, but i can't find a way how to retrieve for each D365 Module, their appropriate Menus items.

For example: i'm on AP module, and i want to get all the AOT Menu items belong to this module, in AOT they are represented as a display menu items, but i can't find a way how to get them by using a simple job.

Thanks.

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    303,730 Super User 2026 Season 1 on at

    Hi Adnane,

    What is the business requirement you are trying to fulfill? Is it related to getting the data on the user interface, or do you need a list for development purposes? What exactly do you mean with "a simple job"?

  • AdnDalhi Profile Picture
    336 on at

    I need to list all Sub Menus, and display Menu items for the AP module.

  • André Arnaud de Calavon Profile Picture
    303,730 Super User 2026 Season 1 on at

    Where do you need list this? Please tell if a user needs a form or you need a list from Visual Studio? The requirement is still not clear to me.

  • AdnDalhi Profile Picture
    336 on at

    I have created a specific table, with 2 columns (Label, name), what i need exactly is to retrieve a list of all display Menu items on AP module for example.

    I started by this X++ code:

    var displayMenuItem = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::MenuItemDisplayNames();

    while (displayMenuItem.MoveNext())

    {

         info(strFmt("Menu Item display name:  %1",displayMenuItem.Current));

    }

    But The result here is > all Display Menu items on D365.

    AXMenus.PNG

    What i need exactly is to get, and store all those Menu Items of AP module(Menu),

    I hope the idea is clear Now :) ?

  • Jie G Profile Picture
    Microsoft Employee on at
    Hi Adnane Dalhi,
    Elements are grouped by Models in AOT, So you can get all the menu items in a Model. Please refer to the demo code below:
    class RunnableClass1
    {        
        
        public static void main(Args _args)
        {    
            RunnableClass1 c = new  RunnableClass1();
            set result = new set(Types::String);
    
            var modelName = 'Application Suite';
    
            var axMenuItemType = new Microsoft.Dynamics.AX.Metadata.MetaModel.AxMenuItemDisplay();
            var t = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::MenuItemDisplayNames();  // Why Enumerator?
            while ( t.moveNext() )
            {
                var tname = t.get_current(); 
    
                if ( c.inModel(ModelName, tname, axMenuItemType.GetType()) )
                {
                    result.add(tname);
                    continue;
                }
    
            }
            
        }
    
        public boolean inModel(str modelDisplayName, str objname, System.Type type)
        {
            var models = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetModelsOfMetadataArtifact(objname, type);
            var modelsEnumerator = models.getEnumerator();
            while (modelsEnumerator.moveNext())
            {
                Microsoft.Dynamics.AX.Metadata.MetaModel.ModelInfo modelInfo = modelsEnumerator.Current;
                if( ModelDisplayName == modelInfo.DisplayName )
                {
                    return true;
                }
            }
    
            return false;
        }
    
    }
  • André Arnaud de Calavon Profile Picture
    303,730 Super User 2026 Season 1 on at

    Hi Adnane,

    The coding you shared, would be better readable if you use the code applet ('</>') in the rich formatting option.

    You can interact with classes like SysDictMenu, SysDictMenuNode and SysDictMenuTreeNode to get your result.

    The code shared by Ada is evaluating the menu items per model not a menu module.

  • AdnDalhi Profile Picture
    336 on at

    Thanks a lot, but is there any way to get them by module ( AP, or AR..)

  • André Arnaud de Calavon Profile Picture
    303,730 Super User 2026 Season 1 on at

    Hi Adnane,

    Yes, using the classes as I had provided in my previous reply.

  • Jie G Profile Picture
    Microsoft Employee on at

    Hi Adnane,

    According to Andre's suggestion, I can get all the display menu items in Account Payable module using following demo code.

    public static void main(Args _args)
        {       
            TreeNode menuItemNode = TreeNode::findNode(@"\Menus\AccountsPayable");
            SysDictMenu _menu;
            _menu = SysDictMenu::newTreeNode(menuItemNode);
    
            str          menuLabel;
    
            boolean iterateMenus(SysDictMenu _cmenu)
            {
                SysMenuEnumerator menuEnum = _cmenu.getEnumerator();
                SysDictMenu subMenu;  
                SysDictMenu parentSubMenu;
                boolean found;                 
    
                while (menuEnum.moveNext())
                {
                    subMenu = menuEnum.current();
    
                    if (subMenu.isMenu() || subMenu.isMenuReference())
                    {
                        print subMenu.object().treeNodePath()+" is Menu";
                       
                        found = iterateMenus(subMenu);
                        if (found) 
                        {
                            return found;
                        }
                    }
                    else if (subMenu.isMenuItem()&& subMenu.menuItem().type() == MenuItemType::Display)
                    {
                        print subMenu.object().treeNodePath();   
                    }
                }
                return false;
            }
    
            iterateMenus(_menu);
           
        }


  • AdnDalhi Profile Picture
    336 on at

    Thanks a lot Ada, this is what i was looking for,

    but while executing, i got some menus that dont exist in D365 FO Main page,

    When i checked i found a subMenu property named (IsDisplayedInContentArea), i added it on the If control line, but it's not working, the result is nothing.

                    else if (subMenu.isMenuItem()&& subMenu.menuItem().type() == MenuItemType::Display 
    && subMenu.Object().AOTgetProperty("IsDisplayedInContentArea") == NoYes::Yes) { print subMenu.object().treeNodePath(); }


    2nd Question, is there any way to list the form names related to those MenuItems.




Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans