MS Dynamics CRM 2011 :Ribbon Customization Part-1-Add a custom tab to Microsoft Dynamics CRM 2011 ribbon

If you need the basics on  Ribbon customization please check my earlier blog  MS Dynamics CRM 2011 :Ribbon Customization Part-1

Today  we will look at how to add a tab  and a custom button to the tab to the existing CRM 2011 ribbon

  1. Create a new Solution with the name ‘AddCustomTabSolution’
  2. Add the Exisitng’ApplicationRibbon’ to the above solution
  3. Save and Export the solution
  4. Unzip the Solution , Edit the Customization File.
  5. The open the customization file  it appears as below.  

<ImportExportXml xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”&gt;

 <Entities></Entities>

 <Roles></Roles>

  <Workflows></Workflows>

  <FieldSecurityProfiles></FieldSecurityProfiles>

  <Templates />

  <RibbonDiffXml>

    <CustomActions />

    <Templates>

      <RibbonTemplates Id=”Mscrm.Templates”></RibbonTemplates>

    </Templates>

    <CommandDefinitions />

    <RuleDefinitions>

      <TabDisplayRules />

      <DisplayRules />

      <EnableRules />

    </RuleDefinitions>

    <LocLabels />

  </RibbonDiffXml>

  <EntityMaps />

  <EntityRelationships />

  <OrganizationSettings />

  <optionsets />

  <Languages>

    <Language>1033</Language>

  </Languages>

</ImportExportXml>

6. Now our task is to add a Tab to the Ribbon . as from our earlier post we know that whatever we need to do(Add, Remove, Hide items) on the Ribbon we need to do under CustomActions

7. Adding a Custom Action By Specifying the CustomAction 

<CustomAction Id=”Mscrm.ISV.MyCustomTabAction” Location=”Mscrm.Tabs._children” Sequence=”1000″>
        <CommandUIDefinition>

          <Tab Id=”Mscrm.ISV.MyCustomTab” Command=”Mscrm.ISV.MyCustomTabCommand” Description=”Custom Tab” Title=”Custom Tab” Sequence=”1000″>

            <Scaling Id=”Mscrm.Isv.Global.Scaling”>

              <MaxSize Id=”Mscrm.Isv.Global.Group0.MaxSize” Sequence=”10″ GroupId=”Mscrm.Isv.Global.Group0″ Size=”Large” />

              <Scale Id=”Mscrm.Isv.Global.Group0.Scale.Medium” Sequence=”20″ GroupId=”Mscrm.Isv.Global.Group0″ Size=”Medium” />

              <Scale Id=”Mscrm.Isv.Global.Group0.Scale.Small” Sequence=”30″ GroupId=”Mscrm.Isv.Global.Group0″ Size=”Small” />

              <Scale Id=”Mscrm.Isv.Global.Group0.Scale.Popup” Sequence=”40″ GroupId=”Mscrm.Isv.Global.Group0″ Size=”Popup” />

            </Scaling>

            <Groups Id=”Mscrm.Isv.Global.Groups”>

              <Group Id=”Mscrm.Isv.Global.Group0″ Sequence=”10″ Command=”Mscrm.Isv.Global.Group0″ Title=”Custom Group1″ Description=”Custom Group1″ Template=”Mscrm.Templates.Flexible”>

              </Group>

            </Groups>

          </Tab>

        </CommandUIDefinition>

      </CustomAction>

8. Specify the Command Definition

<CommandDefinitions>

      <CommandDefinition Id=”Mscrm.ISV.MyCustomTabCommand”>

        <EnableRules />

        <DisplayRules>

          <DisplayRule Id=”Mscrm.ISV.MyCustomTabCommand” />

        </DisplayRules>

        <Actions />

      </CommandDefinition>

      <CommandDefinition Id=”Mscrm.Isv.Global.Group0″>

        <EnableRules />

        <DisplayRules />

        <Actions />

      </CommandDefinition>

      </CommandDefinitions>

9.   Specify the display Rule

<DisplayRule Id=”Mscrm.ISV.MyCustomTabAction”>

       <OrRule>

          <Or>

            <CrmClientTypeRule Type=”Web” />   

          </Or>

        </OrRule>

       </DisplayRule>

10.  Save the Customization file, Zip the Solution and import the Solution and Refresh the Web page you can see the Custom Tab with the Custom Button inside a Custom Group  and the ribbon now looks like as shown in the screenshot.

Adding a Custom Tab to MS CRM 2011



The entire customization file  can be Downloaded here .
Unmanaged Solution can be downloaded here

Advertisements

MS Dynamics CRM 2011 :Ribbon Customization Part-1

What is a Ribbon?
Ribbon is the primary location for controls that are used to perform actions in Microsoft Dynamics CRM as shown below. Ribbons facilitate the user s to have the right command at the right place meaning it shows the context sensitive controls and commands

MS Dynamics CRM 2011 Ribbon

Ribbon Contains the Following Elements
1. Tabs
2. Tabs contains the Groups
3. Groups contains the Controls as shown in the below screenshot ( an application level Ribbon)

How many different levels the Ribbon customization can be done?
the answer would be 4 levels and they are

  • Application Level (For Ex: Adding a Tab that will be visible on the entire application)
    • Web Application Ribbon
      • Jewel –A blue tab with the label File that appears far left of the ribbon ( this is also displayed in the entity form) .This provides a Menu item
      • Basic Home Tab:- The basic home tab is displayed on the main application ribbon whenever an alternative tab is not defined, For example, this tab is displayed when you view the Microsoft Dynamics CRM Resource Center
    • Outlook Ribbon
      • Microsoft Office Outlook 2003 and 2007
      • Microsoft Office Outlook 2010
  • Form Level (For Ex: Adding a Tab on all Forms)
  • Grid Level (For Ex: Adding a Tab that will be displayed in grid pages)
  • Entity Level (Fro Ex: Removing a button from the entity)

RibbonDiffXml

Microsoft Dynamics CRM contains default <RibbonDiffXml> (RibbonDiffXml) definitions for all ribbons in the application

The structure of RibbonDiffXml looks like below when we export the RibbonDiffXml from the brand new CRM 2011 installation.

<RibbonDiffXml>

  <CustomActions />

  <Templates>

    <RibbonTemplates Id=”Mscrm.Templates”></RibbonTemplates>

  </Templates>

  <CommandDefinitions />

  <RuleDefinitions>

    <TabDisplayRules />

    <DisplayRules />

    <EnableRules />

  </RuleDefinitions>

  <LocLabels />

</RibbonDiffXml> 

CustomActions : we can do the following actions on the items under custom actions

  • Add an item
  • Replace an item
  • Remove an item
  • Hide an Item

Templates : Collection of Ribbon Templates

Command Definitions :Contains the Commands for the ribbon controls

  • EnableRules
  • Display Rules
  • Actions 
    • Javascript Fucntions
    • URL
    • Outlook command

RuleDefinitons : Contains collection of Rule definitions which include

  • Tab Display Rules : Specify the  conditions  when Tab will display
  • Display Rules :Rule used to display a ribbon element or reference to a “Display Rule “ from a command definition
  • Enable Rules : Enable or disable a ribbon element or   to reference a n “Enable Rule “from  a command definition

LocLables : Specifies a text string associated with a language code.

RibbonNotSupported  :To indicate Entity Doesn’t support the Ribbon. << this is not shown in the above RibbonDiffXml>> ( we will see how this will work in another post)