In this post I will provide a guide on how to do ribbon bar's button hiding by Security Role(s).

I recently worked with a client on displaying Out-of-the-Box ribbon bar buttons based on security role(s). The client was skeptical to use any JavaScripts. So I presented the following no JavaScript aproach.

It boils down to the following steps:

  1. Create a dummy entity called "Ribbon Visibility"
  2. Create and export the solution containing entity/entities that you want to change (Entity ONLY)
  3. Export the Ribbon Definition of the entity/entities info using SDK's ExportRibbonXML code
  4. Locate the ribbon definition(s) from step #3 XMLs
  5. Extract the "CommandDefinition" and include the new "DisplayRules"
  6. Specify the new "DisplayRules" from #5
  7. Reimport the solution and verify!

Let say we would like to hide "Start Dialog" and "Run Report" from the Accounts in this example

1.  Create a dummy entity called "Ribbon Visibility"

 2.  Create and export the solution containing entity/entities that you want to change (Entity ONLY)


There is no need to add the dependencies. We just need the entity for ribbon.

Extract the .zip file and open the cutomizations.xml, under ImportExportXml Entities Entity, you can locate a line specific for account; in this section, locate the <RibbonDiffXml> tag


This is the section we would like to modify for this example.

3.  Export the Ribbon Definition of the entity/entities info using SDK's ExportRibbonXML code

Gareth Tucker has a great blog post to accomplish this:

4.  Locate the ribbon definition(s) from step #3 XMLs

Since we are modifying the account's ribbon, let's open it from the following path:


I personally use Notepad++ for the ease of use, but do modify it with the editor of your choice for XML.

There are three sets of different ribbons for any entity:

  • HomeGrid, the list view of the entity in the main CRM Window
  • Form, the entity's form
  • SubGrid, the assoicated view of this entity from other related entity

The modifications we are making here are for HomeGrid. Let's navigate to the sections that specify those controls.

The controls are being categorized in order as shown on screen from the XML. 

For "Start Dialog", it is under "Workflow" group; "Run Report" is under the "Export Data" group as highlighted.

5.  Extract the "CommandDefinition"

What do we do after finding those two lines? The objective here is to hide the buttons by finding their definition.  You can also locate the "Command" or series of action of the button. 

If you search the Command Name within this file, you will find the CommandDefinition below.


This is the portion we would like to override to incorporate the hiding logic. We are going to add a DisplayRules called "WF.AccessRibbonVisibilityForm" here. Paste this back to the customizations.xml from step #2 and we get this:


We are going to define what "WF.AccessRibbonVisibilityForm" is on next step.

6.  Specify the new "DisplayRules" from #5.

<DisplayRule Id="WF.AccessRibbonVisibilityForm">
    <EntityPrivilegeRule EntityName="wf_ribbonvisibility" PrivilegeType="Read" PrivilegeDepth="Local" />

We are using EntityPrivilegeRule here. It reads as:

"We are going to display the button if the user has Local level Read previlege on entity wf_ribbonvisibility"

From here, you should be able to see there is potential to implement layer of visibility levels based on how we set up each security role on the custom entity (Ribbon Visibility).

For the possible values on EntityPrivilegeRule, please refers to

The final customizations.xml (from step #2) should look like this

<CustomActions />
  <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
  <CommandDefinition Id="Mscrm.RunInteractiveWorkflowSelected">
	  <EnableRule Id="Mscrm.SelectionCountExactlyOne" />
	  <EnableRule Id="Mscrm.RunWorkflowSelected" />
	  <EnableRule Id="Mscrm.VisualizationPaneNotMaximized" />
	  <DisplayRule Id="WF.AccessRibbonVisibilityForm" />
	  <JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.runScript" Library="/_static/_common/scripts/RibbonActions.js">
		<CrmParameter Value="SelectedControlSelectedItemReferences" />
		<CrmParameter Value="SelectedEntityTypeCode" />
  <CommandDefinition Id="Mscrm.ReportMenu.Grid">
	  <EnableRule Id="Mscrm.VisualizationPaneNotMaximized" />
	  <DisplayRule Id="Mscrm.ReadReport" />
	  <DisplayRule Id="WF.AccessRibbonVisibilityForm" />
	<Actions />
  <TabDisplayRules />
	<DisplayRule Id="WF.AccessRibbonVisibilityForm">
	  <EntityPrivilegeRule EntityName="wf_ribbonvisibility" PrivilegeType="Read" PrivilegeDepth="Basic" />
  <EnableRules />
<LocLabels />


7.  Reimport the solution and verify!

 Rezip the modified customizations.xml back to the exported solution file and reimport it back into the system. All that is left to do is to alter the "Ribbon Visibility" privilege to show/hide the buttons we are trying to hide here.

All visible roles except System Administrator see after the changes:


Happy coding fellow CRM developers!