In this blog, we will show you what to do so that you can show/hide different tabs on the navigation menu for different portal user, based on their web roles.
Firstly, the Power Apps Portal navigation menu should be configured in the ‘Web Link Sets’ Entity within Dynamics. If you are logged in with the Administrator web role, you might see the embedded CMS on the portal next to the menu bar that allows you to change the menu orders or add/remove menus. I would not recommend using that feature, as it can be easily move to the wrong place.
In order to show different tabs for different users, we need to create a new Web Link Set. In my example, we have Primary Navigation and Secondary Navigation. I would like to show ‘Administrators’ the Primary Navigation and other users the Secondary Navigation.
To configure the navigation menu, simply add/remove ‘Web Links’ records of each ‘Web Link Sets’ record, set the order and select Published in the Publishing State field. Below I have the ‘Primary Navigation’ Web link set.
The flyout menu can also be configured, simply set the Parent Web Link field and the relationship will be added. Refer to the screenshot below.
Open the Header Web Template and you can see it is using the ‘Default’ Web Link Set for everyone, that is where we are going to put our custom condition in. We simply add one If check to see if the current user contains the web role of ‘Administrators’ If Yes, assign the ‘Primary Navigation’ to variable primary_nav, otherwise assigned the ‘Secondary Navigation’.
In addition to that, it is also recommended to only display the menu for the Logged in portal user. Add another If statement for the user.firstname. It will continue with our logic above if Portal user logged in, otherwise display the ‘Third Navigation’ for visitor user.
In my example above, I use the ‘Web Role’ of the portal user as the filter, and programmatically switch the ‘Web Link Set’ so different users see different navigation menu. Depending on your business requirement, you can choose other parameters as your filter, however, it is required to create one ‘Web Link Set’ for each scenario. This will be a lot easier in comparison to adding all the logic to one specific Web Link Set.