web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to hide out of box buttons based on security roles on sharepoint document entity

(4) ShareShare
ReportReport
Posted on by 2,510
Hi, is it possible to hide the highlighted buttons based on user security role on sharepoint document entity? Thanks
 
I have the same question (0)
  • Krishna Acharya Profile Picture
    123 on at

    Hello 

    Yes, you can hide out-of-the-box (OOB) buttons such as Edit, Subscribe, and others on the SharePoint Document Associated View in Dynamics 365 based on user security roles. However, this requires customization using either JavaScript or the Ribbon Workbench.

    Here's a quick overview:

    Ribbon Workbench (Recommended for Classic UI) : 


    1. Open Ribbon Workbench in XrmToolBox.

    2. Load your solution that includes the Document Locations or Related Documents entity.

    3. Select the buttons you want to hide (e.g., Edit, Subscribe).

    4. Add a Display Rule:

      • Use a Custom JavaScript function to check user roles.

      • Or use a ValueRule with a specific privilege or security role

      Publish the changes.

    JavaScript (Form Level Customization) :

    You can write JS code to hide the ribbon buttons dynamically. This is sample code you can do changes according to your requirements.
    function hideButtonsBasedOnRole() {
        var userRoles = Xrm.Utility.getGlobalContext().userSettings.roles.getAll();
        // Check if user does NOT have the required role
        var hasRole = userRoles.some(function (role) {
            return role.name === "Your Security Role Name";
        });
        if (!hasRole) {
            // Hide buttons using DOM manipulation (works for some UI parts)
            var btn = document.querySelector("[title='Edit']");
            if (btn) btn.style.display = "none";
        }
    }
     

    If you found my answer helpful, please mark it as verified.

    Thank you!

    – Krishna

  • sdnd2000 Profile Picture
    2,510 on at
     
    I tried the both approaches, none of them worked for sharepoint subgrid. 
  • Suggested answer
    Daivat Vartak (v-9davar) Profile Picture
    7,835 Super User 2025 Season 2 on at
    Hello sdnd2000,
     

    Yes, it is absolutely possible to hide the highlighted buttons ("Document Location", "Open Location", "Add Location", "Edit Location") on the SharePoint Document entity grid based on a user's security role in Dynamics 365. You can achieve this through Ribbon Workbench.

    Here's a step-by-step guide on how to do it:

    Prerequisites:

    • Solution with SharePoint Document Entity: Ensure the SharePoint Document entity is part of an unmanaged solution that you can edit in Ribbon Workbench.
    • Ribbon Workbench: You need to have the Ribbon Workbench tool installed and connected to your Dynamics 365 environment. You can download it from the XrmToolBox.
    • Identify Target Security Roles: Know the names of the security roles for which you want to hide these buttons.

    •  

    Steps:

    1. Open Ribbon Workbench:

      • Launch XrmToolBox.
      • Connect to your Dynamics 365 environment.
      • Open the Ribbon Workbench tool.

      •  

    2. Load Your Solution:

      • In Ribbon Workbench, select the unmanaged solution that contains the SharePoint Document entity.

      •  

    3. Navigate to the SharePoint Document Entity:

      • In the "Entities" pane on the left, find and expand the "SharePoint Document" entity.
      • Click on the "HomepageGrid" (this is the ribbon for the associated grid view).

      •  

    4. Identify the Buttons:

      • In the visual editor in the center, locate the highlighted buttons: "Document Location", "Open Location", "Add Location", and "Edit Location". They will likely be within a specific group on the ribbon.

      •  

    5. Create Display Rules: For each button you want to hide based on security roles, you'll need to create a Display Rule:

      • In the "Solution Elements" pane on the right, under "Display Rules", right-click and select "New Display Rule".
      • Give the Display Rule a meaningful name (e.g., HideDocumentLocationForNonAdmin).
      • In the "Properties" pane for the new Display Rule, set the "Default" property to false. This means the button will be hidden by default.
      • Click "Add Step" in the "Steps" section.
      • Set the "Action" to Check Privilege.
      • Set the "Object Type" to Entity.
      • Set the "Object Name" to sharepointdocument.
      • Set the "Privilege" to Read. (This step is often included as a base requirement, but you can adjust based on your needs).
      • Click "Add Step" again.
      • Set the "Action" to Check User Privilege.
      • Set the "Privilege Type" to Role.
      • In the "Data" field, enter the GUID of the security role that should see the button. You'll need to get the GUID of the security role from the Dynamics 365 Security Role settings.
      • Important: If you want to hide the button for multiple roles, you'll need to create a separate Display Rule for each role and then combine them using an OR group (see step 7).
      • Tip: To hide the button for everyone except specific roles, set the "Default" to true and then create Display Rules that return false for the roles that should not see the button.

      •  

    6. Assign Display Rules to Buttons:

      • Select the "Document Location" button on the ribbon.
      • In the "Properties" pane for the button, find the "Display Rules" section.
      • Click "Add" and select the Display Rule you created for the roles that should see this button.
      • Repeat this process for the "Open Location", "Add Location", and "Edit Location" buttons, assigning the appropriate Display Rules.

      •  

    7. Handling Multiple Security Roles (Optional - for showing/hiding based on multiple roles):

       

      • If you need to show or hide a button for a group of security roles, you can use Or Groups within your Display Rules.
      • Create a new Display Rule.
      • Set "Default" to false (to hide by default).
      • Click "Add Step" and select "Add OrGroup".
      • Within the new OrGroup, add multiple "Check User Privilege" steps (as described in step 5), each checking for a different security role GUID that should allow the button to be visible.

    8. Publish Your Changes:

       

      • Once you have configured the Display Rules for all the buttons and assigned them, click the "Publish Solution" button in Ribbon Workbench.
      • Important: Only publish the solution containing the SharePoint Document entity customizations to avoid unintended changes in other areas.

      •  

    9.  

    Finding Security Role GUIDs:

    1. In Dynamics 365, go to Settings > Security > Security Roles.
    2. Open the security role you want to use in your Display Rule.
    3. In the address bar of your browser, you will find the GUID of the security role after id=. Copy this GUID.

    4.  

    Example Scenario (Hiding "Document Location" for all roles except "System Administrator"):

    1. Create a Display Rule named ShowDocumentLocationForAdmin.
    2. Set "Default" to false.
    3. Add a "Check User Privilege" step with "Privilege Type" as Role and the GUID of the "System Administrator" role in the "Data" field.
    4. Assign the ShowDocumentLocationForAdmin Display Rule to the "Document Location" button.

    5.  

    Remember to test your changes thoroughly with users assigned to different security roles to ensure the buttons are hidden and visible as expected.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • sdnd2000 Profile Picture
    2,510 on at
    Hi, Daivat Vartak,
     
    Is HomepageGrid correct? I do not even see those buttons there. It looks like they are on the subgrid.
     
     
     
     
  • Suggested answer
    Tom_Gioielli Profile Picture
    2,776 Super User 2025 Season 2 on at
    A bunch of the AI answers around Ribbon Workbench seem to always hallucinate doing something with "HomePageGrid", but I don't believe that has ever been a thing. Some blog somewhere must have mentioned it and now they keep reinforcing it with every AI generated answer that keeps referencing it. 
     
    ¯\_(ツ)_/¯
     
    Back to your question, you can hide the buttons for everyone easily through just right-clicking and selecting "hide" on ribbon workbench subgrid view you have highlighted below. If you want to do it dynamically based on a security role, you'll need to write a JavaScript function that is able to check for the user security associations before adding that to the button. Below is a blog that runs through how to do that.
     
     
    Good luck!
     
    If this answer helped, please consider marking as verified.
  • Vahid Ghafarpour Profile Picture
    12,090 Super User 2025 Season 2 on at

    If any of the responses helped resolve your issue, please take a moment to mark the best answer. This helps others in the community quickly find solutions to similar problems.

    To do this, simply click the "Does this answer your question?" button on the most helpful response and like the helpful posts. If your issue is still unresolved, feel free to provide more details so the community can assist further!

    Thanks for being an active part of the Dynamics 365 Community! 😊

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans