Dynamics 365 July Update includes a new attribute type called “MultiSelect Option Set”. It is like the existing “Option Set” attribute type, except now a user can make multiple selections.
We can use this to let the users select which items are available in the navigation area for a specific record type on the form. In this blog, I will walk through the steps to achieve this.
First, we need to create a new MultiSelect Option Set to let the users select the items that can to be hidden in the navigation area. I wanted the users to be able to hide 4 items – Entitlements, Activities, Social Profiles, Connections.
Then I added a new web resource called mag_navigation.js and added the following code in it. The logic compares label of the selected values, and matches it with the name of the navigation item. If the match is found, then visibility of that navigation item is set to false.
I added the newly created “Hide from Navigation” on Contact main form.
Then I added “mag_navigation.js” on the contact main form libraries. To hide the navigation items when the form loads, I added an OnLoad event handler on the main form. This event handler calls “ShowHideNavigationItems” function from “mag_navigation.js” library.
I also added an OnChange event handler on “Hide from Navigation” field which calls ShowHideNavigationItems function. This will allow the users to show/hide navigation items without reloading the web page.
Then I saved and published all the changes.
Let’s see this logic in action. I opened a contact record with no options selected for field “Hide From Navigation” and the following screenshot shows what a user would see in the navigation area for that record (considering the fact that they have right privileges to see these entities).
Then I selected Activities, and Connections options in the “Hide From Navigation” field.
In the navigation area, Activities and Connections no longer appear.
By unticking Activities option in “Hide From Navigation” field, the Activities relationship reappeared in the navigation area. The same happens when this record is opened, and that’s why an onLoad event handler was used.