Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Hide "Related" Tab on Forms in UI for non-Admin Users

Posted on by 20

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! 

  • Wahaj Rashid Profile Picture
    Wahaj Rashid 11,319 on at
    RE: Hide "Related" Tab on Forms in UI for non-Admin Users

    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?').

  • sofijak Profile Picture
    sofijak 20 on at
    RE: Hide "Related" Tab on Forms in UI for non-Admin Users

    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!

  • Suggested answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 11,319 on at
    RE: Hide "Related" Tab on Forms in UI for non-Admin Users

    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:

    pastedimage1618525669230v1.png

    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)

  • Suggested answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 11,319 on at
    RE: Hide "Related" Tab on Forms in UI for non-Admin Users

    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:

    • Enable form with Related tab only for System Administrators.
    • Enable form without Related tab to Normal users.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans