A few weeks ago, I shared a small solution to be able to configure additional workspaces as the default startup page. I got some feedback already which is now updated in a new version of the solution. In this post, you can read the technical details of how the new startup pages are added and visible on the form.
I would like to start by thanking everyone who downloaded and tried out the solution. I got feedback on the license conditions. I have changed the license to fully align with the standards of the MIT license. Next to this update, there is another small update to ensure users will only see the workspace options which are part of their security permissions. You can find a link to the download below in the post.
My research started by looking at the User options form. I wanted to know the source of the standard options and where the initial startup page is stored in the database. When you open the SysUserSetup form, you can browse to the form object belonging to the Initial page.
It appears that the control DefaultPageCombo has no properties filled for the data binding, so the options list and table storage is managed via x++ coding. The property Auto declaration has the value Yes, so searching for coding where this control is used would be an easy job.
The first match is on the method loadDefaultPages() which is the actual method defining the options for the combo box. When you analyze the coding, the list is managed in a class called SysMenuNavigationDataProvider. The conclusion of analyzing and extending this class is written below. Another interesting learning is that this class provides a label and menu item name for the default startup pages. For each combo option, a value will be stored in a container. This will be the match between the value the user will choose and the menu item stored in the database.
The ValidateWrite() method contains the lookup of the menu item name value from the variable based on the chosen option by the user. The technical menu item name will be stored in the table SysUserInfo field StartPage.
Extend default startup pages
Now we know that the default pages are provided with a label caption and menu item, we can check how to extend the class which provides the default options as mentioned above. The first attempt was to find the class SysMenuNavigationDataProvider and look at the methods called from the method loadDefaultPages() on the User options form.
The first method called is initializeFromObjectParsing(). The method itself is initializing the class with specific values for a certain menu. The menu name is provided with: NavigationConstants::dashboard. This returns the value StartPageMenu. When looking at the menu in the AOT, then this menu is empty. There are several menu extensions that will combine all the default menu options for the initial page. Now, if you have an ISV solution or other customization which would require a new page as a startup page, you wouldn’t need the utility I shared before. You can simply create a new menu extension of the menu StartPageMenu and add your workspace(s) or other forms.
As I wanted to have a configurable option, I needed to continue my exploration to check how to dynamically add values to these menu items.
This method is also preparing a variable (sysMenuNavigationObject) with all menu items from the StartPageMenu. This class is used for multiple purposes where data will be used for different menus. It would be possible to extend some methods and add menu items dynamically, but I haven’t looked deeply at the impact (performance and risk). For sure the extension should have restrictions implemented for one particular menu: StartPageMenu.
I decided to extend the form method loadDefaultPages as this would not have an impact on other features. This can be done with a Chain of Command method. I shared my coding below.
The method will ensure that first the standard pages will be built for the combo box. Then it will loop a custom table that I created to store the additional Startup pages. Per record, it will add an option to the DefaultPageCombo control. Besides, it will add an option in the container with the corresponding menu item.
The hasMenuItemAccess statement is added in release 220.127.116.11 to ensure each business user will only be able to see pages part of their own permissions. With help of this coding, the users can see the standard and additional configured menu items on the User options form. Being able to have a menu item stored in the field on the user options is not the only part you need to extend. A class called SysLoadStartPage will get the menu item from the user options. In this class, there is a method that will check if the selected menu item is a valid menu item. This will check if the menu item is part of the StartPageMenu. If not, it will open the Default Dashboard.
To ensure the setup on the user options will work, also this method needs to be extended to ensure it will consider the configured startup page as valid.
In this extension, it is checked if the menu item has been added to the table with startup pages. The permission check is added in the 18.104.22.168 release. Also when you would create your own extensions for startup pages, you have to ensure that you also extend the standard method to ensure the selected startup page will work for the user.
The latest version of the Startup pages solution can be downloaded and used for free. If you have feedback or questions, please use the contact form or leave a comment below. Despite I’m working for a global ISV (To-Increase), this solution is not related to my company. I’m sharing on personal title.
The download contains a deployable package that can be used for Microsoft Dynamics 365 F&O 10.0.24 and above. It also contains the source code in form of a model file and a project export. For installation, you can consult the standard documentation from Microsoft.
There is more…
In the solution I created, there is another extension for the action menu bar to show additional options to manage the configurable startup pages. These menu items will be visible to system administrators. If you want to give access to other users, you can add the duty Maintain startup pages to a security role.
As the technical menu item name is stored, we can use any display menu item that is accessible from the main menu. This is not restricted to workspace-type of forms.
Conclusion: If you want to extend the options for the startup pages using coding, you have to ensure you not only create an extension to show more startup pages on the User options form, but also extend the method which determines if a startup page is a valid page. With a customization, you can extend the StartPageMenu to have new workspaces from your solution part of the application.
As technical menu item name is stored, we can use any menu item. Any? Read also my other blog where it is explained how the bla bla bla bla : Is a privilege the only check for granting access to forms?
I do hope you liked this post and will add value for you in your daily work as a professional. If you have related questions or feedback, don’t hesitate to use the Comment feature below.
That’s all for now. Till next time!