Hiding a Ribbon Button in Dynamics CRM 2011

Roshan Mehta, 14 November 2011

There are many areas of Microsoft Dynamics CRM 2011 that can be customized to allow an organisation to make the software run the way they want it to run. These include the out-of-the-box customization tools made available within the CRM user interface, as well as advanced customization features such as the modification of XML in order to change the main CRM navigation and ribbon configuration. In this post, I will show you how easy it is to hide an out-of-the-box ribbon button.

 Hiding a Ribbon Button in Dynamics CRM 2011

One of our customers requested that a custom Notes entity was built to replace the out-of-the-box Notes. We could have just modified the Security Roles and removed all privileges to the out-of-the-box Notes entity for all users, however, it was still a requirement to have the ability to attach a file to CRM records. For this reason, we needed to hide the “Add a Note” button on the ribbon for all entities. Here’s how we did it:

1. Navigate to Settings -> Solutions -> and click on New.
2. Enter “Global Ribbon” as the Display Name and choose an appropriate Publisher.
3. Enter “1.0” as the Version Number.
4. Click on Save.
5. On the solution toolbar, click on Add Existing and select “Application Ribbons”.

 Hiding a Ribbon Button in Dynamics CRM 2011

6. Click on Save and Close.

In the solutions list, select the solution we have just created and click on Export Solution. Step through the wizard and export the solution as unmanaged. The solution will be downloaded as a ZIP file into your Downloads folder. Extract the zip file and open up the customizations.xml file in an appropriate editor such as Visual Studio. Locate the <CustomActions> tag and enter the following code:

<HideCustomAction Location="" HideActionId="Magnetism.HideCustomAction.Form.AddNote"/>

Note that the Location attribute is empty at this stage. We need to find out the correct location that holds the “Add a Note” button. To do this, we can use the Microsoft Dynamics CRM 2011 SDK.

 

1. In the Microsoft Dynamics CRM 2011 SDK, open up up  “\sdk\samplecode\cs\client\ribbon\exportribbonxml\exportedribbonxml\accountribbon.xml”

 

2. Search for “addnote” and note the ID of the Button.

 

 Hiding a Ribbon Button in Dynamics CRM 2011

We can see that the ID of the Button is Mscrm.HomepageGrid.account.AddFile. Remember that we want to hide the button for all entities on both the grid and the form, so the IDs we want to use is Mscrm.HomepageGrid.{!EntityLogicalName}.AddNote and Mscrm.Form.{!EntityLogicalName}.AddNote.

Our XML to hide the button now becomes:

      <HideCustomAction Location="Mscrm.Form.{!EntityLogicalName}.AddNote" HideActionId="Magnetism.HideCustomAction.Form.AddNote"/>

      <HideCustomAction Location="Mscrm.HomepageGrid.{!EntityLogicalName}.AddNote" HideActionId="Magnetism.HideCustomAction.HomepageGrid.AddNote"/>

 

ZIP up the “[Content_Types].xml”, “customizations.xml”, and “solution.xml” and re-import the solution back into the system. Be sure to publish all customizations after import. You will now see that the “Add a Note” button is hidden on all form and grid ribbons for all entities.