Sonoma Partners Microsoft CRM and Salesforce Blog

Security Settings for Displaying a Native Ribbon Button

Today’s guest blogger is Blake Scarlavai, a Senior CRM Developer at Sonoma Partners.

Having trouble figuring out why a native ribbon button isn’t displaying?  An easy way to determine the permissions required for the ribbon button is to export the entity or application ribbon. 

For example, we were trying to set up a security role and allow the permission to import data.  The ‘Import Data’ ribbon button is usually displayed in the application ribbon but it wasn’t displaying for a user with our new security role. 

clip_image002

To debug this, I took to the application ribbon xml.  I used this handy sample code to easily export the application ribbon from my organization - http://msdn.microsoft.com/en-us/library/hh547439.aspx.  Another option would be to add the application ribbon to a standalone solution and export that solution to retrieve the ribbon xml.

Once the application ribbon xml is retrieved, I was able to search for the word ‘import’ to find the following button definition:

<Button Id="Mscrm.BasicHomeTab.Tools.ImportData" Command="Mscrm.ImportData" Sequence="10" Alt="$Resources:Ribbon.Jewel.ImportData" LabelText="$Resources:Ribbon.Jewel.ImportData" Image16by16="/_imgs/ribbon/ImportData_16.png" Image32by32="/_imgs/ribbon/importdata32.png" TemplateAlias="o1" ToolTipTitle="$Resources:Mscrm_BasicHomeTab_Tools_ImportData_ToolTipTitle" ToolTipDescription="$Resources:Mscrm_BasicHomeTab_Tools_ImportData_ToolTipDescription" />

From the button definition, I was able to find the Command Id ‘Mscrm.ImportData’ (highlighted above).  I then searched the ribbon xml for ‘Mscrm.ImportData’ to find the following Command Definition so that I could identify the DisplayRule.

<CommandDefinition Id="Mscrm.ImportData">
  <EnableRules />
  <DisplayRules>
    <DisplayRule Id="Mscrm.NotOffline" />
    <DisplayRule Id="Mscrm.ImportData" />
  </DisplayRules>
  <Actions>
    <JavaScriptFunction FunctionName="Mscrm.ImportData_0" Library="$Webresource:Ribbon_main_system_library.js" />
  </Actions>
</CommandDefinition>

As highlighted above, the DisplayRule has the same name as the CommandDefinition so I continued to search the ribbon xml for ‘Mscrm.ImportData’ to find the following DisplayRule definition:

<DisplayRule Id="Mscrm.ImportData">
  <EntityPrivilegeRule EntityName="import" PrivilegeType="Create" PrivilegeDepth="Basic" />
  <EntityPrivilegeRule EntityName="import" PrivilegeType="Delete" PrivilegeDepth="Basic" />
  <EntityPrivilegeRule EntityName="import" PrivilegeType="Read" PrivilegeDepth="Basic" />
  <EntityPrivilegeRule EntityName="import" PrivilegeType="Write" PrivilegeDepth="Basic" />
  <EntityPrivilegeRule EntityName="importmap" PrivilegeType="Create" PrivilegeDepth="Basic" />
  <EntityPrivilegeRule EntityName="importmap" PrivilegeType="Read" PrivilegeDepth="Basic" />
  <EntityPrivilegeRule EntityName="importmap" PrivilegeType="AppendTo" PrivilegeDepth="Basic" />
</DisplayRule>

As you can see, the DisplayRule definition above explicitly lays out the not-necessarily-obvious permissions needed for the ‘Import Data’ button to display.  We compared this with our security role permissions to discover that we were missing Delete rights on the import entity (Data Import).  Once this privilege was added, our ‘Import Data’ button magically appeared.

clip_image002[4]