MS Dynamics CRM 2011 :Ribbon Customization Part-2-Understanding the Ribbon customization

Revisit my earlier post and dig in to the details of how we added a tab and also button to the tab.

  1.       As we need to Add a “Tab” , as we understood from the Post 1, any modifications to the ribbon definitions should be done at  <Custom Actions>
  2. See the picture below,<Custom Action> can contain <Custom Action> or <Hide Action>
    RibbonDiffXml Dynamics CRM 2011

    RibbonDiffXML

     

  3. <Custom Action> should have Id, Location ,Sequence, Title, CommandUIDefinition

So we added the following Custom Action

<CustomAction Id=Mscrm.Isv.GlobalCustomAction Location=Mscrm.Tabs._children Sequence=100>
 
 
 

 

4.  < CommandUIDefinition > can contain any  type (for ex: button,tab etc.,) what is displayed in the  above Screenshot. But we are interested to add Tab,So refer the screenshot for the Properties and the elements Tabtaype contains so we added the following < CommandUIDefinition >

< CommandUIDefinition >       

<Tab Id=”Mscrm.Isv.Global” Command=”Mscrm.Isv.Global” 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”>

                <Controls Id=”Mscrm.Isv.Global.Group0.Controls”>

                  <Button Id=”Mscrm.Isv.Global.Group0.Control0″ Command=”Mscrm.Isv.Global.Group0.Control0″ LabelText=”$LocLabels:Mscrm.Isv.Global.Group0.Control0.LocLabel” ToolTipTitle=”$LocLabels:Mscrm.Isv.Global.Group0.Control0.LocLabel” ToolTipDescription=”$LocLabels:Mscrm.Isv.Global.Group0.Control0.ToolTip.LocLabel” Image16by16=”/_imgs/area/18_home.gif” Image32by32=”/_imgs/area/18_home.gif” Image16by16Class=”ms-crm-Upgraded-Ribbon-Image16″ Image32by32Class=”ms-crm-Upgraded-Ribbon-Image32″ Sequence=”10″ TemplateAlias=”o1″ />

                </Controls>

              </Group>

            </Groups>

          </Tab>

        </CommandUIDefinition>

5.   After this we need to specify the <CommandDefinitions> which Specifies a set of rules that control how a ribbon element is displayed and actions to perform that can be referenced by ribbon elements and controls See the below screenshot for how the Command definition should be done

CommandDefinetion Dynamics CRM 2011 ribbon

CommandDefinetion Dynamics CRM 2011 ribbon

<CommandDefinitions>

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

        <EnableRules />

        <DisplayRules>

          <DisplayRule Id=”Mscrm.Isv.Global.Group0.Control0″ />

        </DisplayRules>

        <Actions>         

        </Actions>

      </CommandDefinition>

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

        <EnableRules />

        <DisplayRules>

          <DisplayRule Id=”Mscrm.Isv.Global” />

        </DisplayRules>

        <Actions />

      </CommandDefinition>

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

        <EnableRules />

        <DisplayRules />

        <Actions />

      </CommandDefinition>

    </CommandDefinitions>

6.  Then we need to add the  Rule definetions. Please check the below screenshot for the details how the Rule definitions should be configured so we added

Rule DefinetionGlobal Microsoft dynamics CRM 2011

<RuleDefinitions>

      <TabDisplayRules>

        <TabDisplayRule TabCommand=”Mscrm.Isv.Global”>

          <PageRule Address=”*” />

        </TabDisplayRule>

      </TabDisplayRules>

      <DisplayRules>

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

           <OrRule>

            <Or>

              <CrmClientTypeRule Type=”Web” />

            </Or>

           </OrRule>

        </DisplayRule>

        <DisplayRule Id=”Mscrm.Isv.Global.Group0.Control0″>

          <CrmOfflineAccessStateRule State=”Offline” InvertResult=”true” />

        </DisplayRule>

      </DisplayRules>

      <EnableRules />

    </RuleDefinitions>

7.  At the End we have added thee Lockables where you can specify the text to display in the ribbon labels and tooltips

<LocLabel Id=”Mscrm.Isv.Global.Group0.Control0.LocLabel”>

        <Titles>

          <Title languagecode=”1033″ description=”Custom Button” />

        </Titles>

      </LocLabel>

      <LocLabel Id=”Mscrm.Isv.Global.Group0.Control0.ToolTip.LocLabel”>

        <Titles>

          <Title languagecode=”1033″ description=”Custom Button” />

        </Titles>

      </LocLabel>

    </LocLabels>

Advertisements

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