Friday, December 6, 2013

“Run Report” button on custom entities forms

In CRM2013 the “Run Report” button is missing on custom entities. The button is not available even if you have selected display in the “Forms of the related record types”. The problem is the “Display Rule” named “Mscrm.HideOnCommandBar” associated with the “Run Report” button. It is a default behaviour for custom entities.

There are 2 different ways to display the “Run Report” button on the custom entities.

By adding the "CommandDefinition” to the ribbon definition of the entity.

  1. Create a new solution in CRM, add contact entity to the solution and export the solution.
  2. Open the customization file from the exported solution and look for <RibbonDiffXML> . It will look like the following XML.
  3. <RibbonDiffXml>
      <CustomActions />
      <Templates>
        <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
      </Templates>
      <CommandDefinitions />
      <RuleDefinitions>
        <TabDisplayRules />
        <DisplayRules />
        <EnableRules />
      </RuleDefinitions>
      <LocLabels />
    </RibbonDiffXml>
    
  4. Replace the highlighted line yellow with the following XML
  5. <CommandDefinition Id="Mscrm.ReportMenu.Form">
        <EnableRules>
          <EnableRule Id="Mscrm.FormStateNotNew" />
        </EnableRules>
        <DisplayRules>
          <DisplayRule Id="Mscrm.ReadReport" />
        </DisplayRules>
        <Actions />
      </CommandDefinition>
    </CommandDefinitions>
    
  6. Save the file and overwrite the Customization file in your exported solution zip file with this file.
  7. Import the solution zip file and publish it. It’s done.

By using  Ribbon Work Bench 2013


Report button can be easily restored using “Ribbon Work Bench 2013”. Check http://community.dynamics.com/crm/b/develop1/archive/2013/09/06/how-to-restore-a-hidden-button-on-the-crm-2013-command-bar.aspx for the step by step instructions.
Note: Make sure in the step 4 of the instructions,  “Form” is selected in the upper right corner as shown in the following screen shot.

image