Export (0) Print
Expand All

Walkthrough: Add a Custom Tab to a Specific Entity

[Applies to: Microsoft Dynamics CRM 2011]

This walkthrough describes how to add a custom tab to the Opportunity entity. The procedure to add a custom tab to any entity will be the similar.

TipTip
A managed solution that includes the goal of this walkthrough is available in the Microsoft Dynamics CRM SDK download at SDK\Walkthroughs\Ribbon\AddaCustomTabtoaSpecificEntity.zip.

Because it is a managed solution, you can install (import) it to view the customized ribbon. You can then uninstall (delete) it to remove it from the system.

If you install this managed solution, make sure that you uninstall it before you try the walkthrough steps.

Before you can begin you must have a clear set of requirements. The following images describe the goal:

Opportunity entity form ribbon

A custom tab for the Opportunity enity form

Opportunity entity grid ribbon

A custom tab for the Opportunity entity grid

Account form ribbon with the related Opportunity grid selected

A custom tab for the opportunity entity subgrid

The following are the requirements for the custom tab that will be met in this example:

  1. Will appear only for the Opportunity entity.

  2. Will appear to the right of any other tabs.

  3. Will appear in the following areas:

    • Opportunity form

    • Opportunity grid

    • Opportunity sub grid, to the right of the Opportunities tab in the List Tools contextual group.

  4. Will have the label Custom Tab.

  5. The custom tab for each ribbon will have one group and four buttons as described in the following table.

     

    Tab Id Group Id Button Id

    Sample.Form.opportunity.CustomTab

    Sample.Form.opportunity.CustomTab.FirstGroup

    Sample.Form.opportunity.CustomTab.FirstGroup.FirstButton

    Sample.Form.opportunity.CustomTab.FirstGroup.SecondButton

    Sample.Form.opportunity.CustomTab.FirstGroup.ThirdButton

    Sample.Form.opportunity.CustomTab.FirstGroup.FourthButton

    Sample.Grid.opportunity.CustomTab

    Sample.Grid.opportunity.CustomTab.FirstGroup

    Sample.Grid.opportunity.CustomTab.FirstGroup.FirstButton

    Sample.Grid.opportunity.CustomTab.FirstGroup.SecondButton

    Sample.Grid.opportunity.CustomTab.FirstGroup.ThirdButton

    Sample.Grid.opportunity.CustomTab.FirstGroup.FourthButton

    Sample.SubGrid.opportunity.CustomTab

    Sample.SubGrid.opportunity.CustomTab.FirstGroup

    Sample.SubGrid.opportunity.CustomTab.FirstGroup.FirstButton

    Sample.SubGrid.opportunity.CustomTab.FirstGroup.SecondButton

    Sample.SubGrid.opportunity.CustomTab.FirstGroup.ThirdButton

    Sample.SubGrid.opportunity.CustomTab.FirstGroup.FourthButton

  6. Each button will reference a Web resource image to display icons as shown in the following table.

    TipTip
    You can import the Microsoft Dynamics CRM SDK sample images managed solution to add these icons to your organization. The solution is available in the downloadable files for the SDK at SDK\Walkthroughs\Ribbon\MicrosoftCRMSDKSampleImages.zip.

    Or, you can create your own image Web resources by using the names in the following list.

     

    Button Web Resource Name Action

    FirstButton

    A 16x16 pixel icon displaying the number 1

    sample_/icons/1Icon16x16.png

    Display Message: “Button 1 action performed”.

    A 32x32 pixel icon displaying the number 1

    sample_/icons/1Icon32x32.png

    SecondButton

    A 16x16 pixel icon displaying the number 2

    sample_/icons/2Icon16x16.png

    Display Message: “Button 2 action performed”.

    A 32x32 pixel icon displaying the number 2

    sample_/icons/2Icon32x32.png

    ThirdButton

    A 16x16 pixel icon displaying the number 3

    sample_/icons/3Icon16x16.png

    Display Message: “Button 3 action performed”.

    A 32x32 pixel icon displaying the number 3

    sample_/icons/3Icon32x32.png

    FourthButton

    A 16x16 pixel icon displaying the number 4

    sample_/icons/4Icon16x16.png

    Display Message: “Button 4 action performed”.

    A 32x32 pixel icon displaying the number 4

    sample_/icons/4Icon32x32.png

  7. When clicked, each button will display a message "Button [N] action performed." where N represents the number of the button.

  8. Each tab, group, and button will have a localizable label. Buttons will also have a tooltip.

noteNote
This walkthrough does not show how to configure scaling for the group in the tab. In this example, the limited number of buttons on the tab will not provide an opportunity for scaling to function because the width of the window cannot be reduced to the point where scaling would begin to take effect.

If you are defining a custom tab that will include more buttons and groups, you should also define scaling definitions. For more information, see Define Scaling for Ribbon Elements.

  1. By exporting and making changes only to the ribbon for the Opportunity entity, you will meet requirement 1.

    You can export the whole default solution, including the Opportunity entity, but to minimize the total file size, we recommend that you create a new solution and add the Opportunity entity to it.

    Create a New Solution

  2. Export the Solution

  1. Each entity does not have a specific collection of tabs so this tab must be added to the general collection of application tabs: Mscrm.Tabs.

    noteNote
    To restrict this tab from appearing for all entities, you must apply a tab display rule that includes a restriction to only apply this tab for a specific entity.

  1. Create a script Web resource named sample_ShowMessage.js.

    noteNote
    The full name of the script Web resource you create depends on the solution it is created in. For this sample, the solution publisher customization prefix is sample. The default solution publisher prefix is new. You may have to change how you reference the name of this Web resource in the following example XML if the name of the script Web resource you use is different.

    For more information, see Script (JScript) Web Resources and JScript Libraries for Microsoft Dynamics CRM.

  2. Set the source of this Web resource to the following example:

    function show(number){alert("Button "+number+" action performed.");}
    
  3. Save and publish the script Web resource.

  1. Extract the compressed solutions file.

  2. Open the customizations.xml file.

    TipTip
    Although you can edit the customization.xml file by using any text editor, we recommend that you use Microsoft Visual Studio or another XML editing application that supports XSD schema validation. This will help avoid XML validation errors when you import the ribbon.

    Associate the customizations.xml file with the customizationsSolution.xsd file. You can find this schema in the SDK\Schemas\CustomizationsSolution.xsd file in the SDK download package.

    For more information, see Prepare to edit the XML.

  3. Locate the default RibbonDiffXml node shown in the following example:

    <RibbonDiffXml>
     <CustomActions />
     <Templates>
      <RibbonTemplates Id="Mscrm.Templates">
      </RibbonTemplates>
     </Templates>
     <CommandDefinitions />
     <RuleDefinitions>
      <TabDisplayRules />
      <DisplayRules />
      <EnableRules />
     </RuleDefinitions>
     <LocLabels />
    </RibbonDiffXml>
    
  4. Edit the <RuleDefinitions> (RibbonDiffXml) node to define <TabDisplayRules> (RibbonDiffXml) to support requirement 1 as shown in the following example:

    <TabDisplayRules>
      <TabDisplayRule TabCommand="Sample.Form.opportunity.CustomTab" >
        <EntityRule EntityName="opportunity"
                    Context="Form"
                    AppliesTo="PrimaryEntity" />
      </TabDisplayRule>
      <TabDisplayRule TabCommand="Sample.Grid.opportunity.CustomTab" >
        <EntityRule EntityName="opportunity"
                    Context="HomePageGrid" />
      </TabDisplayRule>
      <TabDisplayRule TabCommand="Sample.SubGrid.opportunity.CustomTab" >
        <EntityRule EntityName="opportunity"
                    Context="SubGridStandard" />
        <EntityRule EntityName="opportunity"
                    Context="SubGridAssociated" />
      </TabDisplayRule>
    </TabDisplayRules>
    
  5. Edit the <LocLabels> (RibbonDiffXml) node to set the localized labels for requirement 8.

    noteNote
    You can enter text directly into the XML for labels. However, using localized labels as shown in the following example makes re-use of text and localization easier:

    <LocLabels>
      <LocLabel Id="Sample.opportunity.CustomTab.Title">
        <Titles>
          <Title languagecode="1033"
                  description="Custom Tab"/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.Description">
        <Titles>
          <Title languagecode="1033"
                  description="A custom tab for the Opportunity entity."/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.Title">
        <Titles>
          <Title languagecode="1033"
                  description="First Group"/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.SecondGroup.Title">
        <Titles>
          <Title languagecode="1033"
                  description="Second Group"/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.ThirdGroup.Title">
        <Titles>
          <Title languagecode="1033"
                  description="Third Group"/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText">
        <Titles>
          <Title languagecode="1033"
                  description="First Button"/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.FirstButton.ToolTipDescription">
        <Titles>
          <Title languagecode="1033"
                  description="The first button in the first group."/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText">
        <Titles>
          <Title languagecode="1033"
                  description="Second Button"/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.SecondButton.ToolTipDescription">
        <Titles>
          <Title languagecode="1033"
                  description="The second button in the first group."/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText">
        <Titles>
          <Title languagecode="1033"
                  description="Third Button"/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.ThirdButton.ToolTipDescription">
        <Titles>
          <Title languagecode="1033"
                  description="The third button in the first group."/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText">
        <Titles>
          <Title languagecode="1033"
                  description="Fourth Button"/>
        </Titles>
      </LocLabel>
      <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.FourthButton.ToolTipDescription">
        <Titles>
          <Title languagecode="1033"
                  description="The fourth button in the first group."/>
        </Titles>
      </LocLabel>
    </LocLabels>
    
    
  6. Edit the <CommandDefinitions> (RibbonDiffXml) node to add 18 commands, one for each tab, group, and button.

    The <CommandDefinition> (RibbonDiffXml) consolidates a set of enable rules, display rules, and actions associated with a control.

    noteNote
    In this example, you use a standard set of existing enable and display rules.

    • The enable rule Mscrm.Enabled sets the control to always be enabled.

    • The display rule Mscrm.CanWriteOpportunity requires that the user be associated with a security role that grants them the write privilege on the Opportunity entity.

    The enable rules and display rules you use will depend on the functionality contained in the actions for each button.

    noteNote
    Because the custom tabs will be displayed on the form, grid, and sub grid; separate commands allow for clearly defining the expected behavior in each location. In the following example, because the CommandDefinitions are very simple and do not vary based on the location, it may be more efficient to define only six command definitions and re-use them. Despite this fact, this walkthrough uses 18 separate <CommandDefinition> (RibbonDiffXml) elements to attempt to minimize complexity at the expense of efficiency:

    <CommandDefinitions>
      <!-- Form Command Definitions Start-->
      <CommandDefinition Id="Sample.Form.opportunity.CustomTab">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions />
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.Form.opportunity.FirstGroup">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions />
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.Form.opportunity.FirstButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="1"/>
          </JavaScriptFunction>
    
        </Actions>
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.Form.opportunity.SecondButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="2"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.Form.opportunity.ThirdButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="3"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.Form.opportunity.FourthButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="4"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      <!-- Form Command Definitions End-->
      
      <!-- Grid Command Definitions Start-->
      <CommandDefinition Id="Sample.Grid.opportunity.CustomTab">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions />
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.Grid.opportunity.FirstGroup">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions />
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.Grid.opportunity.FirstButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="1"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.Grid.opportunity.SecondButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="2"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.Grid.opportunity.ThirdButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="3"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.Grid.opportunity.FourthButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="4"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      <!-- Grid Command Definitions End-->
    
      <!-- SubGrid Command Definitions Start-->
      <CommandDefinition Id="Sample.SubGrid.opportunity.CustomTab">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions />
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.SubGrid.opportunity.FirstGroup">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions />
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.SubGrid.opportunity.FirstButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="1"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.SubGrid.opportunity.SecondButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="2"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.SubGrid.opportunity.ThirdButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="3"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      
      <CommandDefinition Id="Sample.SubGrid.opportunity.FourthButton">
        <EnableRules>
          <EnableRule Id="Mscrm.Enabled "/>
        </EnableRules>
        <DisplayRules >
          <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
        </DisplayRules>
        <Actions>
          <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                              FunctionName="show">
            <StringParameter Value="4"/>
          </JavaScriptFunction>
        </Actions>
      </CommandDefinition>
      <!-- SubGrid Command Definitions End-->
    </CommandDefinitions>
    
    
  7. Edit the <CustomActions> (RibbonDiffXml) element to add detail about the form tab

    noteNote
    In the following example, note that the Location attribute value of the form custom action is set to Mscrm.Tabs._children. This is what adds the tab to the collection of application tabs:

    <CustomActions>
      <!-- Form Custom Tab START-->
      <CustomAction Id="Sample.Form.opportunity.CustomTab.CustomAction"
                    Location="Mscrm.Tabs._children"
                    Sequence="40">
        <CommandUIDefinition>
          <Tab Id="Sample.Form.opportunity.CustomTab"
                Command="Sample.Form.opportunity.CustomTab"
                Title="$LocLabels:Sample.opportunity.CustomTab.Title"
                Description="$LocLabels:Sample.opportunity.CustomTab.Description"
                Sequence="40">
            <Scaling Id="Sample.Form.opportunity.CustomTab.Scaling">
              <MaxSize Id="Sample.Form.opportunity.CustomTab.FirstGroup.MaxSize"
                        GroupId="Sample.Form.opportunity.CustomTab.FirstGroup"
                        Sequence="10"
                        Size="LargeMedium" />
            </Scaling>
            <Groups Id="Sample.Form.opportunity.CustomTab.Groups">
              <Group Id="Sample.Form.opportunity.CustomTab.FirstGroup"
                      Command="Sample.Form.opportunity.FirstGroup"
                      Sequence="10"
                      Title="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.Title"
                      Template="Mscrm.Templates.3.3">
                <Controls Id="Sample.Form.opportunity.CustomTab.FirstGroup.Controls">
                  <Button Id="Sample.Form.opportunity.CustomTab.FirstGroup.FirstButton"
                          ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                          ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.ToolTipDescription"
                          Command="Sample.Form.opportunity.FirstButton"
                          Sequence="10"
                          LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                          Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                          Image16by16="$webresource:sample_/icons/1Icon16x16.png"
                          Image32by32="$webresource:sample_/icons/1Icon32x32.png"
                          TemplateAlias="o1" />
                  <Button Id="Sample.Form.opportunity.CustomTab.FirstGroup.SecondButton"
                          ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                          ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.ToolTipDescription"
                          Command="Sample.Form.opportunity.SecondButton"
                          Sequence="20"
                          LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                          Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                          Image16by16="$webresource:sample_/icons/2Icon16x16.png"
                          Image32by32="$webresource:sample_/icons/2Icon32x32.png"
                          TemplateAlias="o1" />
                  <Button Id="Sample.Form.opportunity.CustomTab.FirstGroup.ThirdButton"
                          ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                          ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.ToolTipDescription"
                          Command="Sample.Form.opportunity.ThirdButton"
                          Sequence="30"
                          LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                          Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                          Image16by16="$webresource:sample_/icons/3Icon16x16.png"
                          Image32by32="$webresource:sample_/icons/3Icon32x32.png"
                          TemplateAlias="o1" />
                  <Button Id="Sample.Form.opportunity.CustomTab.FirstGroup.FourthButton"
                          ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                          ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.ToolTipDescription"
                          Command="Sample.Form.opportunity.FourthButton"
                          Sequence="40"
                          LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                          Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                          Image16by16="$webresource:sample_/icons/4Icon16x16.png"
                          Image32by32="$webresource:sample_/icons/4Icon32x32.png"
                          TemplateAlias="o1" />
                </Controls>
              </Group>
            </Groups>
          </Tab>
        </CommandUIDefinition>
      </CustomAction>
      <!-- Form Custom Tab END-->
    
    </CustomActions>
    
    
  8. Edit the <CustomActions> (RibbonDiffXml) element to add a <CustomAction> (RibbonDiffXml) for the grid tab. In this example, there are two significant differences between the form and grid custom actions:

    • The naming convention used for Id attributes begins with Sample.Grid rather than Sample.Form.

    • The Tab.Sequence value is significantly higher (500). This is necessary to force the tab to display to the right of any other tabs. The value 500 was chosen in the following example as an arbitrary high value:

    <!-- Grid Custom Tab START-->
    <CustomAction Id="Sample.Grid.opportunity.CustomTab.CustomAction"
                  Location="Mscrm.Tabs._children"
                  Sequence="40">
      <CommandUIDefinition>
        <Tab Id="Sample.Grid.opportunity.CustomTab"
              Command="Sample.Grid.opportunity.CustomTab"
              Title="$LocLabels:Sample.opportunity.CustomTab.Title"
              Description="$LocLabels:Sample.opportunity.CustomTab.Description"
              Sequence="500">
          <Scaling Id="Sample.Grid.opportunity.CustomTab.Scaling">
            <MaxSize Id="Sample.Grid.opportunity.CustomTab.FirstGroup.MaxSize"
                      GroupId="Sample.Grid.opportunity.CustomTab.FirstGroup"
                      Sequence="10"
                      Size="LargeMedium" />
          </Scaling>
          <Groups Id="Sample.Grid.opportunity.CustomTab.Groups">
            <Group Id="Sample.Grid.opportunity.CustomTab.FirstGroup"
                    Command="Sample.Grid.opportunity.FirstGroup"
                    Sequence="10"
                    Title="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.Title"
                    Template="Mscrm.Templates.3.3">
              <Controls Id="Sample.Grid.opportunity.CustomTab.FirstGroup.Controls">
                <Button Id="Sample.Grid.opportunity.CustomTab.FirstGroup.FirstButton"
                        ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                        ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.ToolTipDescription"
                        Command="Sample.Grid.opportunity.FirstButton"
                        Sequence="10"
                        LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                        Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                        Image16by16="$webresource:sample_/icons/1Icon16x16.png"
                        Image32by32="$webresource:sample_/icons/1Icon32x32.png"
                        TemplateAlias="o1" />
                <Button Id="Sample.Grid.opportunity.CustomTab.FirstGroup.SecondButton"
                        ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                        ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.ToolTipDescription"
                        Command="Sample.Grid.opportunity.SecondButton"
                        Sequence="20"
                        LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                        Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                        Image16by16="$webresource:sample_/icons/2Icon16x16.png"
                        Image32by32="$webresource:sample_/icons/2Icon32x32.png"
                        TemplateAlias="o1" />
                <Button Id="Sample.Grid.opportunity.CustomTab.FirstGroup.ThirdButton"
                        ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                        ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.ToolTipDescription"
                        Command="Sample.Grid.opportunity.ThirdButton"
                        Sequence="30"
                        LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                        Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                        Image16by16="$webresource:sample_/icons/3Icon16x16.png"
                        Image32by32="$webresource:sample_/icons/3Icon32x32.png"
                        TemplateAlias="o1" />
                <Button Id="Sample.Grid.opportunity.CustomTab.FirstGroup.FourthButton"
                        ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                        ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.ToolTipDescription"
                        Command="Sample.Grid.opportunity.FourthButton"
                        Sequence="40"
                        LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                        Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                        Image16by16="$webresource:sample_/icons/4Icon16x16.png"
                        Image32by32="$webresource:sample_/icons/4Icon32x32.png"
                        TemplateAlias="o1" />
              </Controls>
            </Group>
          </Groups>
        </Tab>
      </CommandUIDefinition>
    </CustomAction>
    <!-- Grid Custom Tab END-->
    
    
  9. Edit the <CustomActions> (RibbonDiffXml) element to add a custom action for your sub grid tab. Because the sub grid ribbon is displayed using a contextual group within the parent entity ribbon, the sub grid custom action Location attribute value in the following example is set to Mscrm.SubGrid.opportunity.ContextualTabs._children:

    <!-- SubGrid Custom Tab START-->
    <CustomAction Id="Sample.SubGrid.opportunity.CustomTab.CustomAction"
                  Location="Mscrm.SubGrid.opportunity.ContextualTabs._children"
                  Sequence="40">
      <CommandUIDefinition>
        <Tab Id="Sample.SubGrid.opportunity.CustomTab"
              Command="Sample.SubGrid.opportunity.CustomTab"
              Title="$LocLabels:Sample.opportunity.CustomTab.Title"
              Description="$LocLabels:Sample.opportunity.CustomTab.Description"
              Sequence="500">
          <Scaling Id="Sample.SubGrid.opportunity.CustomTab.Scaling">
            <MaxSize Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.MaxSize"
                      GroupId="Sample.SubGrid.opportunity.CustomTab.FirstGroup"
                      Sequence="10"
                      Size="LargeMedium" />
          </Scaling>
          <Groups Id="Sample.SubGrid.opportunity.CustomTab.Groups">
            <Group Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup"
                    Command="Sample.SubGrid.opportunity.FirstGroup"
                    Sequence="10"
                    Title="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.Title"
                    Template="Mscrm.Templates.3.3">
              <Controls Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.Controls">
                <Button Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.FirstButton"
                        ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                        ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.ToolTipDescription"
                        Command="Sample.SubGrid.opportunity.FirstButton"
                        Sequence="10"
                        LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                        Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                        Image16by16="$webresource:sample_/icons/1Icon16x16.png"
                        Image32by32="$webresource:sample_/icons/1Icon32x32.png"
                        TemplateAlias="o1" />
                <Button Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.SecondButton"
                        ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                        ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.ToolTipDescription"
                        Command="Sample.SubGrid.opportunity.SecondButton"
                        Sequence="20"
                        LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                        Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                        Image16by16="$webresource:sample_/icons/2Icon16x16.png"
                        Image32by32="$webresource:sample_/icons/2Icon32x32.png"
                        TemplateAlias="o1" />
                <Button Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.ThirdButton"
                        ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                        ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.ToolTipDescription"
                        Command="Sample.SubGrid.opportunity.ThirdButton"
                        Sequence="30"
                        LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                        Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                        Image16by16="$webresource:sample_/icons/3Icon16x16.png"
                        Image32by32="$webresource:sample_/icons/3Icon32x32.png"
                        TemplateAlias="o1" />
                <Button Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.FourthButton"
                        ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                        ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.ToolTipDescription"
                        Command="Sample.SubGrid.opportunity.FourthButton"
                        Sequence="40"
                        LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                        Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                        Image16by16="$webresource:sample_/icons/4Icon16x16.png"
                        Image32by32="$webresource:sample_/icons/4Icon32x32.png"
                        TemplateAlias="o1" />
              </Controls>
            </Group>
          </Groups>
        </Tab>
      </CommandUIDefinition>
    </CustomAction>
    <!-- SubGrid Custom Tab END-->
    
    
  10. Your final modified RibbonDiffXml node will look like the following example:

    <RibbonDiffXml>
      <CustomActions>
        <!-- Form Custom Tab START-->
        <CustomAction Id="Sample.Form.opportunity.CustomTab.CustomAction"
                      Location="Mscrm.Tabs._children"
                      Sequence="40">
          <CommandUIDefinition>
            <Tab Id="Sample.Form.opportunity.CustomTab"
                  Command="Sample.Form.opportunity.CustomTab"
                  Title="$LocLabels:Sample.opportunity.CustomTab.Title"
                  Description="$LocLabels:Sample.opportunity.CustomTab.Description"
                  Sequence="40">
              <Scaling Id="Sample.Form.opportunity.CustomTab.Scaling">
                <MaxSize Id="Sample.Form.opportunity.CustomTab.FirstGroup.MaxSize"
                          GroupId="Sample.Form.opportunity.CustomTab.FirstGroup"
                          Sequence="10"
                          Size="LargeMedium" />
              </Scaling>
              <Groups Id="Sample.Form.opportunity.CustomTab.Groups">
                <Group Id="Sample.Form.opportunity.CustomTab.FirstGroup"
                        Command="Sample.Form.opportunity.FirstGroup"
                        Sequence="10"
                        Title="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.Title"
                        Template="Mscrm.Templates.3.3">
                  <Controls Id="Sample.Form.opportunity.CustomTab.FirstGroup.Controls">
                    <Button Id="Sample.Form.opportunity.CustomTab.FirstGroup.FirstButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.ToolTipDescription"
                            Command="Sample.Form.opportunity.FirstButton"
                            Sequence="10"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                            Image16by16="$webresource:sample_/icons/1Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/1Icon32x32.png"
                            TemplateAlias="o1" />
                    <Button Id="Sample.Form.opportunity.CustomTab.FirstGroup.SecondButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.ToolTipDescription"
                            Command="Sample.Form.opportunity.SecondButton"
                            Sequence="20"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                            Image16by16="$webresource:sample_/icons/2Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/2Icon32x32.png"
                            TemplateAlias="o1" />
                    <Button Id="Sample.Form.opportunity.CustomTab.FirstGroup.ThirdButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.ToolTipDescription"
                            Command="Sample.Form.opportunity.ThirdButton"
                            Sequence="30"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                            Image16by16="$webresource:sample_/icons/3Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/3Icon32x32.png"
                            TemplateAlias="o1" />
                    <Button Id="Sample.Form.opportunity.CustomTab.FirstGroup.FourthButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.ToolTipDescription"
                            Command="Sample.Form.opportunity.FourthButton"
                            Sequence="40"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                            Image16by16="$webresource:sample_/icons/4Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/4Icon32x32.png"
                            TemplateAlias="o1" />
                  </Controls>
                </Group>
              </Groups>
            </Tab>
          </CommandUIDefinition>
        </CustomAction>
        <!-- Form Custom Tab END-->
        <!-- Grid Custom Tab START-->
        <CustomAction Id="Sample.Grid.opportunity.CustomTab.CustomAction"
                      Location="Mscrm.Tabs._children"
                      Sequence="40">
          <CommandUIDefinition>
            <Tab Id="Sample.Grid.opportunity.CustomTab"
                  Command="Sample.Grid.opportunity.CustomTab"
                  Title="$LocLabels:Sample.opportunity.CustomTab.Title"
                  Description="$LocLabels:Sample.opportunity.CustomTab.Description"
                  Sequence="500">
              <Scaling Id="Sample.Grid.opportunity.CustomTab.Scaling">
                <MaxSize Id="Sample.Grid.opportunity.CustomTab.FirstGroup.MaxSize"
                          GroupId="Sample.Grid.opportunity.CustomTab.FirstGroup"
                          Sequence="10"
                          Size="LargeMedium" />
              </Scaling>
              <Groups Id="Sample.Grid.opportunity.CustomTab.Groups">
                <Group Id="Sample.Grid.opportunity.CustomTab.FirstGroup"
                        Command="Sample.Grid.opportunity.FirstGroup"
                        Sequence="10"
                        Title="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.Title"
                        Template="Mscrm.Templates.3.3">
                  <Controls Id="Sample.Grid.opportunity.CustomTab.FirstGroup.Controls">
                    <Button Id="Sample.Grid.opportunity.CustomTab.FirstGroup.FirstButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.ToolTipDescription"
                            Command="Sample.Grid.opportunity.FirstButton"
                            Sequence="10"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                            Image16by16="$webresource:sample_/icons/1Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/1Icon32x32.png"
                            TemplateAlias="o1" />
                    <Button Id="Sample.Grid.opportunity.CustomTab.FirstGroup.SecondButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.ToolTipDescription"
                            Command="Sample.Grid.opportunity.SecondButton"
                            Sequence="20"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                            Image16by16="$webresource:sample_/icons/2Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/2Icon32x32.png"
                            TemplateAlias="o1" />
                    <Button Id="Sample.Grid.opportunity.CustomTab.FirstGroup.ThirdButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.ToolTipDescription"
                            Command="Sample.Grid.opportunity.ThirdButton"
                            Sequence="30"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                            Image16by16="$webresource:sample_/icons/3Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/3Icon32x32.png"
                            TemplateAlias="o1" />
                    <Button Id="Sample.Grid.opportunity.CustomTab.FirstGroup.FourthButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.ToolTipDescription"
                            Command="Sample.Grid.opportunity.FourthButton"
                            Sequence="40"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                            Image16by16="$webresource:sample_/icons/4Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/4Icon32x32.png"
                            TemplateAlias="o1" />
                  </Controls>
                </Group>
              </Groups>
            </Tab>
          </CommandUIDefinition>
        </CustomAction>
        <!-- Grid Custom Tab END-->
        <!-- SubGrid Custom Tab START-->
        <CustomAction Id="Sample.SubGrid.opportunity.CustomTab.CustomAction"
                      Location="Mscrm.SubGrid.opportunity.ContextualTabs._children"
                      Sequence="40">
          <CommandUIDefinition>
            <Tab Id="Sample.SubGrid.opportunity.CustomTab"
                  Command="Sample.SubGrid.opportunity.CustomTab"
                  Title="$LocLabels:Sample.opportunity.CustomTab.Title"
                  Description="$LocLabels:Sample.opportunity.CustomTab.Description"
                  Sequence="500">
              <Scaling Id="Sample.SubGrid.opportunity.CustomTab.Scaling">
                <MaxSize Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.MaxSize"
                          GroupId="Sample.SubGrid.opportunity.CustomTab.FirstGroup"
                          Sequence="10"
                          Size="LargeMedium" />
              </Scaling>
              <Groups Id="Sample.SubGrid.opportunity.CustomTab.Groups">
                <Group Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup"
                        Command="Sample.SubGrid.opportunity.FirstGroup"
                        Sequence="10"
                        Title="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.Title"
                        Template="Mscrm.Templates.3.3">
                  <Controls Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.Controls">
                    <Button Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.FirstButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.ToolTipDescription"
                            Command="Sample.SubGrid.opportunity.FirstButton"
                            Sequence="10"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText"
                            Image16by16="$webresource:sample_/icons/1Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/1Icon32x32.png"
                            TemplateAlias="o1" />
                    <Button Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.SecondButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.ToolTipDescription"
                            Command="Sample.SubGrid.opportunity.SecondButton"
                            Sequence="20"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText"
                            Image16by16="$webresource:sample_/icons/2Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/2Icon32x32.png"
                            TemplateAlias="o1" />
                    <Button Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.ThirdButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.ToolTipDescription"
                            Command="Sample.SubGrid.opportunity.ThirdButton"
                            Sequence="30"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText"
                            Image16by16="$webresource:sample_/icons/3Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/3Icon32x32.png"
                            TemplateAlias="o1" />
                    <Button Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.FourthButton"
                            ToolTipTitle="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                            ToolTipDescription="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.ToolTipDescription"
                            Command="Sample.SubGrid.opportunity.FourthButton"
                            Sequence="40"
                            LabelText="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                            Alt="$LocLabels:Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText"
                            Image16by16="$webresource:sample_/icons/4Icon16x16.png"
                            Image32by32="$webresource:sample_/icons/4Icon32x32.png"
                            TemplateAlias="o1" />
                  </Controls>
                </Group>
              </Groups>
            </Tab>
          </CommandUIDefinition>
        </CustomAction>
        <!-- SubGrid Custom Tab END-->
      </CustomActions>
      <Templates>
        <RibbonTemplates Id="Mscrm.Templates">
        </RibbonTemplates>
      </Templates>
      <CommandDefinitions>
        <!-- Form Command Definitions Start-->
        <CommandDefinition Id="Sample.Form.opportunity.CustomTab">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions />
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.Form.opportunity.FirstGroup">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions />
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.Form.opportunity.FirstButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="1"/>
            </JavaScriptFunction>
    
          </Actions>
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.Form.opportunity.SecondButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="2"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.Form.opportunity.ThirdButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="3"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.Form.opportunity.FourthButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="4"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
        <!-- Form Command Definitions End-->
    
        <!-- Grid Command Definitions Start-->
        <CommandDefinition Id="Sample.Grid.opportunity.CustomTab">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions />
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.Grid.opportunity.FirstGroup">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions />
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.Grid.opportunity.FirstButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="1"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.Grid.opportunity.SecondButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="2"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.Grid.opportunity.ThirdButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="3"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.Grid.opportunity.FourthButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="4"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
        <!-- Grid Command Definitions End-->
    
        <!-- SubGrid Command Definitions Start-->
        <CommandDefinition Id="Sample.SubGrid.opportunity.CustomTab">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions />
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.SubGrid.opportunity.FirstGroup">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions />
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.SubGrid.opportunity.FirstButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="1"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.SubGrid.opportunity.SecondButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="2"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.SubGrid.opportunity.ThirdButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="3"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
    
        <CommandDefinition Id="Sample.SubGrid.opportunity.FourthButton">
          <EnableRules>
            <EnableRule Id="Mscrm.Enabled "/>
          </EnableRules>
          <DisplayRules >
            <DisplayRule  Id="Mscrm.CanWriteOpportunity"/>
          </DisplayRules>
          <Actions>
            <JavaScriptFunction Library="$webresource:sample_ShowMessage.js"
                                FunctionName="show">
              <StringParameter Value="4"/>
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
        <!-- SubGrid Command Definitions End-->
      </CommandDefinitions>
      <RuleDefinitions>
        <TabDisplayRules>
          <TabDisplayRule TabCommand="Sample.Form.opportunity.CustomTab" >
            <EntityRule EntityName="opportunity"
                        Context="Form"
                        AppliesTo="PrimaryEntity" />
          </TabDisplayRule>
          <TabDisplayRule TabCommand="Sample.Grid.opportunity.CustomTab" >
            <EntityRule EntityName="opportunity"
                        Context="HomePageGrid" />
          </TabDisplayRule>
          <TabDisplayRule TabCommand="Sample.SubGrid.opportunity.CustomTab" >
            <EntityRule EntityName="opportunity"
                        Context="SubGridStandard" />
            <EntityRule EntityName="opportunity"
                        Context="SubGridAssociated" />
          </TabDisplayRule>
        </TabDisplayRules>
        <DisplayRules/>
        <EnableRules/>
      </RuleDefinitions>
      <LocLabels>
        <LocLabel Id="Sample.opportunity.CustomTab.Title">
          <Titles>
            <Title languagecode="1033"
                    description="Custom Tab"/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.Description">
          <Titles>
            <Title languagecode="1033"
                    description="A custom tab for the Opportunity entity."/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.Title">
          <Titles>
            <Title languagecode="1033"
                    description="First Group"/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.SecondGroup.Title">
          <Titles>
            <Title languagecode="1033"
                    description="Second Group"/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.ThirdGroup.Title">
          <Titles>
            <Title languagecode="1033"
                    description="Third Group"/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.FirstButton.LabelText">
          <Titles>
            <Title languagecode="1033"
                    description="First Button"/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.FirstButton.ToolTipDescription">
          <Titles>
            <Title languagecode="1033"
                    description="The first button in the first group."/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.SecondButton.LabelText">
          <Titles>
            <Title languagecode="1033"
                    description="Second Button"/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.SecondButton.ToolTipDescription">
          <Titles>
            <Title languagecode="1033"
                    description="The second button in the first group."/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.ThirdButton.LabelText">
          <Titles>
            <Title languagecode="1033"
                    description="Third Button"/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.ThirdButton.ToolTipDescription">
          <Titles>
            <Title languagecode="1033"
                    description="The third button in the first group."/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.FourthButton.LabelText">
          <Titles>
            <Title languagecode="1033"
                    description="Fourth Button"/>
          </Titles>
        </LocLabel>
        <LocLabel Id="Sample.opportunity.CustomTab.FirstGroup.FourthButton.ToolTipDescription">
          <Titles>
            <Title languagecode="1033"
                    description="The fourth button in the first group."/>
          </Titles>
        </LocLabel>
      </LocLabels>
    </RibbonDiffXml>
    
    

  1. Open Microsoft Dynamics CRM 2011 and view the Opportunities sub area of the Navigation Pane to view the Opportunity grid ribbon.

  2. Verify the following:

    • The Custom Tab appears to the right of any other tabs.

    • The Custom Tab tab displays one group and four buttons.

    • All groups and buttons display the expected text for labels and tooltips.

    • The expected message is displayed when you click each button.

  3. Open an opportunity record to view the form ribbon.

  4. Verify that the form ribbon matches the grid ribbon.

  5. Open the Potential Customer record and click the Opportunities link in the Sales area.

  6. Verify that the Custom Tab appears to the right of the Opportunities tab within the List Tools contextual group.

  7. Open other entities to verify that the custom tab is only displayed for the Opportunity entity.

Microsoft Dynamics CRM 2011
Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.

Community Additions

Show:
© 2014 Microsoft