After developing a new form in Microsoft Dynamics 365 F&O, you need to add a menu item in order for users to be able to access your new form or other object. In this article I will show you how to create menu items in D365. As well as explain many of the other useful things you can do using the menu item properties.
What Are Menus and Menu Items?
In Microsoft Dynamics 365 F&O, menu items are the links that can be clicked on to access forms, reports, classes, jobs, and queries.
In 365, on the left hand side, there is a navigation pane. Click on the navigation pane to expand it. Then click ‘Modules’. All of the modules that your user has access to will be shown. Click on a module, and a pane will open. Behind the scenes the pane for this module is known as a ‘Menu’ in the Application Explorer.
In a D365 cloud hosted development environment, open Visual Studio. The Visual Studio Dynamics 365 F&O extension will already by installed. This will allow you to see menus that you would not normally see with a standard Visual Studio install.
Next, go to View>Application Explorer.
Expand the ‘User Interface’ node. Followed by the ‘Menus’ node.
You can see all of the menus in the system.
Expand any of the menus. You will see folders underneath that are known as SubMenus.
And underneath the SubMenus you will see Menu Item nodes.
For every folder and link shown in the browser for D365, there is a corresponding SubMenu node in Menu Item node in the Application Explorer in Visual Studio.
Below are the same sub menus and menu items shown from the front end D365 browser.
The primary way to provide a user access to a form, report, or batch job is to add a Menu Item to one or more Menu.
Users are also able to add menu items buttons within other forms that can be accessed using a menu item on a Menu. And in less common scenarios, forms can be opened using x++ code on buttons within forms. However, the most common way to open access other pages, reports, and batch jobs, is using menu items.
Therefore, every developer needs to know how to create menu items in D365, so that users will be able to use what they create.
Please see this Microsoft documentation for more information about menu items in Microsoft Dynamics AX 2012.
Menu Item Types
When you need to create menu items in D365, the first thing you need to decide is what type of Menu Item to create. There is essentially no functional or technical differences between the different types of menu items. However, using the correct menu item will help future developers find your menu item.
There are three types of Menu Items:
- Display Menu Item: Use this type when the menu item will open a form.
- Output Menu Item: Use this type when the menu item will opening an SSRS report.
- Action Menu Item: Use this type when the menu item will run a batch job. Or some other process, such as run by a class.
In Microsoft Dynamics AX 2012 and before, the icon shown next to the menu item link in the application was different depending on what type of menu item you used. This could help clue in the user as to what they could expect would happen after clicking the link.
However, in D365, there is no longer an icon that shows. So to my knowledge, there is no longer an functional or technical difference between the three types. And using the each type is just a way of grouping them together by their operation. So that developers can more easily find them in the list.
Create The Menu Item
In this section, I will walk you through how to create menu items in D365. First, open Visual Studio, running as an administrator.
Next, create a new D365 project. To do this, go to File>New>Project
Select the ‘Dynamics 365’ section from the left, then select the ‘Finance and Operations’ project type.
Enter in a Name for the project and solution name. Then click ‘Ok’.
The solution and project will be created, and shown in the Solution Explorer window.
Right click on the Project node and set the ‘Model’ property to your model. Then click ‘Ok’.
Right click on the project node once more, and then click Add>New item.
In the dialog that opens up, select ‘Display Menu Item’, ‘Output Menu Item’, or ‘Action Menu Item’, depending on what type of object it will open. In this case, I selected ‘Display Menu Item’. Enter a Name, and then click ‘Add’.
In the Solution Explorer window, double click on the menu item node you just created to open it up.
A new windows will open. On the menu item node is shown. There are no other child nodes with menu items.
Right click on the node in the middle window, and then select Properties.
Note: If Properties window shows the fields a greyed out, you likely selected the menu item node from the Solution Explorer or from the Application Explorer. You need to open it, then select the node from the design window.
Menu Item Properties
The next step in how to create menu items in D365, is to set the properties. We have created the menu item object, we need to tell it what to open. And provide a label.
First, go to the ‘Object Type’ property. This property will only take a preset list of options. Form, Class, Query, CueGroup, SSRSReport.
At this point, we are assuming you have already created one of these types of objects. And you are creating a menu item because you want the users to be able to open it. For now, let’s assume you have created a form, so set the Object Type property to ‘Form’.
Secondly, go to the ‘Object’ property. You can either enter the name of the object directly into this field. Or you can use the drop down. The drown down will change what values it shows depending on what ‘Object Type’ you selected in the previous step. If you try to enter in an object name that does not exist, or is not of the specified ‘Object Type’ the system will show a compile error.
I entered ‘rsmVehicle’ which is the name of a custom form I have in my code. But you could also specify an existing Microsoft form such as ‘SalesTable’.
Thirdly, go to the ‘Label’ property. Now that we have assigned what this menu item will open, show, or do, we need to provide the text that will show to the user in their browser. If this menu item is opening a form, often times, you will want to use the same label that was used as the caption for the form. But this label property provides you the control to make it a different label.
Fourthly, you should also fill in the ‘Help text’ property.
Lastly, you can rename the menu item if you would like to more closely match the object this menu item will open. In this case, I will rename the menu item ‘rsmVehicle’ as well.
These are the main properties that need to be set in order for the menu item to work.
Additional Properties
There are some other properties that you may want to set as well. Look at Configuration Key and Country Configuration Key.
Additionally, there are some very useful properties that allow a developer to send information into the form or object that is being called. Specifically the properties are: Enum Type Parameter, Enum Parameters, Parameters, and Query. As well as ‘Multi Select’ and ‘Needs Record’ I will explain these in detail in the next article.
Extend A Menu
After you create menu items in D365, you need to add the menu items to a Menu. Otherwise they will not be shown.
In the Application Explorer, expand User Interface>Menus to see the existing menu items.
You can create your own new Menu for your menu items. However, very often you will want to add your menu item to an existing menu. In this case, you need to extend the base Microsoft Menu. To do that, right click on the Menu node, and select ‘Create Extension’.
This will create a new Menu Extension. You can find the new Menu Extension node under User Interface>Menu Extensions, in the Application Explorer.
If you have already created a Menu Extension for this Menu, it is best to re-use the existing one. You can check if there already exists a Menu Extension by looking in the Menu Extension node. And then confirming that the model that is shown between the square brackets, matching the model you are adding code to.
In my example, I am working in the ‘rsmTutorials’ model. And I can see that there already exists a Menu Extension named ‘AccountsReceivable.rsmTutorials in the [rsmTutorials] model. So in this case, I will just add this Menu Extension to my project and plan to add to it.
Add the Menu to your project, by right clicking on it, and then selecting ‘Add to Project’.
My project now looks like this:
Add The Menu Item To A Menu
Double click on the Menu Extension node to open the designer window.
Optionally, you can right click on the Menu Extension node and select New>SubMenu to add a folder to put menu items into.
I created a SubMenu named ‘rsmVehicles’, and gave it a Label of ‘Vehicles’.
Next, drag the Menu Item that you created on the Menu Extension in the designer. You can drag it into an existing SubMenu or any others that you created. I dragged my Menu Item into the rsmVehicles SubMenu. I also dragged to other menu items into this SubMenu as well.
Lastly, save and compile your solution.
Testing Your Change
There are a couple different ways you can see the results after you create menu items in D365. If you have the URL to the D365 environment, all you need to do is refresh your browser window. This will get the latest code.
If you don’t have the D365 URL, you can also right click the Menu Item in your Visual Studio solution and select ‘Set As Startup Object’.
Then click the ‘Start’ button in Visual Studio. This will open a new browser and call your menu item right away.
Once the new browser window is opened, open the Module that you added your menu items to, and look for the Label you gave to the menu item.
Additionally, you can search for the Label in the ‘search for a page’ box in D365 that always shows at the top of D365.
Conclusion
Without Menu Items, users would never be able to see or run the forms, reports, and processes that developers create. Security can also be used to limit what Menu Items are shown to each user, based on the user roles. Developers can also use Menu Items to call the same forms, for example, but have them work in different ways. I will going into more detail on how to do that in the next article. Thanks!
dear sir
how to disable some main menu itmes from D365fo
it is required as the user is not allowed to use all the menu itms for a role
regards