Hello CRM superstars!
I am looking for a way to hide the "Related" tab on entity forms for non-Admin users (i.e., specific security roles).
I understand that I can remove all relationships directly from the form customization window (Solution>Entity>Forms>Main Form>Navigation in "Home" tab), and I understand that I can also edit the relationship between two entities directly (Solution>Entity>Relationships>Specific Relationship, then select "Do not Display" as Display Option under "Navigation Pane Item for Primary Entity").
Also, I know that I can make it completely disappear from view if I edit form properties and uncheck "Show Navigation Items" in Page Navigation under Display tab. I do not want to completely hide it for everyone, because sys admins need to access Audit History for records.
We already had to customize certain aspects of the form (for example, show/hide other tabs based on current user's assigned Security Roles), so we got that part of the code down at least.
I am wondering if there is a way to do the same for the "Related" tab (hide it for users who are not Sys Admins so that the regular users do not see it if there is nothing there for them to look at).
Just as an FYI, large majority of our entities, views, attributes, apps, relationships are custom. we have Dynamics 365 on-prem, Version 1612 (9.0.24.8) (DB 9.0.24.8).
Thank you kindly for your suggestions!
Hi,
Hiding the Related tab (fully) is not possible, the only way is to copy the form and have different versions (as mentioned earlier).
If any of this approach helps, mark the appropriate answer as verified (Select Yes under 'Did this answer your question?').
Hi Wahaj, thanks for replying! I am advocating for this approach with my users, but they were still eager to find a solution that hides the entire tab based on security roles, not just the items within the tab. I think your approach with two different forms is interesting - we have a lot of entities to deal with, but it is a low-code option at least!
Hi,
I have another approach in my mind.
We can't hide this tab programmatically, but we can hide the Navigation Items under this tab.
We can loop through, formContext.ui.navigation.items collection and call setVisible function to hide all of these.
This will make sure, when a Non-Admin user clicks on Related tab, there are no options listed to navigate:
Here is the sample code:
// Register on Load of the Form, pass execution context as first parameter
function onLoad(executionContext) {
// Get Form Context
const formContext = executionContext.getFormContext();
// Get Navigation collection
const navigations = formContext.ui.navigation.items;
// Get User Roles
const userRoles = Xrm.Utility.getGlobalContext().userSettings.roles;
// Verify if User is Admin
const isAdmin = isAdminRole();
// If not Admin
if (!isAdmin) {
// Hide all related tabs
navigations.forEach(function(item) {
item.setVisible(false);
});
}
}
I have blogged the solution in detail here:
Dynamics 365 CE: Hide Related Tab based on Security Role | CRM Logs (wordpress.com)
Hi,
Thank you for your query.
One way is to copy your form (Save as) to create a new one, and uncheck "Show navigation items".
Enable forms based on the Security Roles, for example:
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156