Ribbon Customization-Part 5-Add a Custom Tab, Custom Group and Custom Buttons to a Form Ribbon, Grid Ribbon for a Specific Entity(Opportunity Entity)

In my earlier post we have seen how to add custom buttons to the Entity Gird Ribbon for opportunity entity in CRM 2011

Now we will see how to add the same buttons to Entity Form level ribbon  and Sub Grid Ribbon ( The Ribbon that will show when the Control is in the Sub grid with in the Opportunity Entity Form and also  Sub grids showing the Opportunity Associated view)

  1. Create a new Solution called ”OpportunityFormlevelRibbon”  then Add Opportunity entity, and any dependency objects  and also the web resource”ShowMessage.js” which we created in the earlier post and export it and save it in  the disk
  2. unzip the solutions and Edit the customizations.xml
  3. Add the below <<CustomActions>> in addition to the existing custom action
  4.    1: <!--CustomAction  for  Tab, group, buttons to display in Form-->

       2:          <CustomAction Id="Sample.Form.opportunity.CustomTab.CustomAction" Location="Mscrm.Tabs._children" Sequence="40">

       3:            <CommandUIDefinition>

       4:              <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">

       5:                <Scaling Id="Sample.Form.opportunity.CustomTab.Scaling">

       6:                  <MaxSize Id="Sample.Form.opportunity.CustomTab.FirstGroup.MaxSize" GroupId="Sample.Form.opportunity.CustomTab.FirstGroup" Sequence="10" Size="LargeMedium" />

       7:                </Scaling>

       8:                <Groups Id="Sample.Form.opportunity.CustomTab.Groups">

       9:                  <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">

      10:                    <Controls Id="Sample.Form.opportunity.CustomTab.FirstGroup.Controls">

      11:                      <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="/_imgs/ribbon/AddEmail_16.png" Image32by32="/_imgs/ribbon/Email_32.png" TemplateAlias="o1" />

      12:                      <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="/_imgs/ribbon/AddEmail_16.png" Image32by32="/_imgs/ribbon/Email_32.png" TemplateAlias="o1" />

      13:                     

      14:                    </Controls>

      15:                  </Group>

      16:                </Groups>

      17:              </Tab>

      18:            </CommandUIDefinition>

      19:          </CustomAction>

      20:  

      21:          <!--CustomAction  for  Tab, group, buttons to display in  Form Subgrid-->

      22:          <CustomAction Id="Sample.SubGrid.opportunity.CustomTab.CustomAction" Location="Mscrm.SubGrid.opportunity.ContextualTabs._children" Sequence="40">

      23:            <CommandUIDefinition>

      24:              <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">

      25:                <Scaling Id="Sample.SubGrid.opportunity.CustomTab.Scaling">

      26:                  <MaxSize Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.MaxSize" GroupId="Sample.SubGrid.opportunity.CustomTab.FirstGroup" Sequence="10" Size="LargeMedium" />

      27:                </Scaling>

      28:                <Groups Id="Sample.SubGrid.opportunity.CustomTab.Groups">

      29:                  <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">

      30:                    <Controls Id="Sample.SubGrid.opportunity.CustomTab.FirstGroup.Controls">

      31:                       <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="/_imgs/ribbon/AddEmail_16.png" Image32by32="/_imgs/ribbon/Email_32.png" TemplateAlias="o1" />

      32:                      <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="/_imgs/ribbon/AddEmail_16.png" Image32by32="/_imgs/ribbon/Email_32.png" TemplateAlias="o1" />                      

      33:                    </Controls>

      34:                  </Group>

      35:                </Groups>

      36:              </Tab>

      37:            </CommandUIDefinition>

      38:          </CustomAction>

  5. Add the below CommandDefinitions  for the above buttons, tab,group
  6.    1: <!--Command Definetions for  Tab, Group, Buttons under Form needs to be included here-->

       2:  

       3:    <CommandDefinition Id="Sample.Form.opportunity.FirstButton">

       4:      <EnableRules />

       5:      <DisplayRules />

       6:      <Actions>

       7:        <Url Address="http://www.microsoft.com"></Url>

       8:      </Actions>

       9:    </CommandDefinition>

      10:    <CommandDefinition Id="Sample.Form.opportunity.SecondButton">

      11:      <EnableRules />

      12:      <DisplayRules />

      13:      <Actions>

      14:        <JavaScriptFunction Library="$webresource:new_/ShowMessage.js" FunctionName="show">

      15:          <StringParameter Value="2" />

      16:        </JavaScriptFunction>

      17:      </Actions>

      18:    </CommandDefinition>

      19:    <CommandDefinition Id="Sample.Form.opportunity.FirstGroup">

      20:      <EnableRules>

      21:        <EnableRule Id="Mscrm.Enabled " />

      22:      </EnableRules>

      23:      <DisplayRules>

      24:        <DisplayRule Id="Mscrm.CanWriteOpportunity" />

      25:      </DisplayRules>

      26:      <Actions />

      27:    </CommandDefinition>

      28:    <CommandDefinition Id="Sample.Form.opportunity.CustomTab">

      29:      <EnableRules>

      30:        <EnableRule Id="Mscrm.Enabled " />

      31:      </EnableRules>

      32:      <DisplayRules>

      33:        <DisplayRule Id="Mscrm.CanWriteOpportunity" />

      34:      </DisplayRules>

      35:      <Actions />

      36:    </CommandDefinition>

      37:  

      38:    <!--Command Definetions for  Tab, Group, Buttons under Form's SubGrid needs to be included here-->

      39:    <CommandDefinition Id="Sample.SubGrid.opportunity.FirstButton">

      40:      <EnableRules />

      41:      <DisplayRules />

      42:      <Actions>

      43:        <Url Address="http://www.microsoft.com"></Url>

      44:      </Actions>

      45:    </CommandDefinition>

      46:    <CommandDefinition Id="Sample.SubGrid.opportunity.SecondButton">

      47:      <EnableRules />

      48:      <DisplayRules />

      49:      <Actions>

      50:        <JavaScriptFunction Library="$webresource:new_/ShowMessage.js" FunctionName="show">

      51:          <StringParameter Value="2" />

      52:        </JavaScriptFunction>

      53:      </Actions>

      54:    </CommandDefinition>

      55:    <CommandDefinition Id="Sample.SubGrid.opportunity.FirstGroup">

      56:      <EnableRules>

      57:        <EnableRule Id="Mscrm.Enabled " />

      58:      </EnableRules>

      59:      <DisplayRules>

      60:        <DisplayRule Id="Mscrm.CanWriteOpportunity" />

      61:      </DisplayRules>

      62:      <Actions />

      63:    </CommandDefinition>

      64:    <CommandDefinition Id="Sample.SubGrid.opportunity.CustomTab">

      65:      <EnableRules>

      66:        <EnableRule Id="Mscrm.Enabled " />

      67:      </EnableRules>

      68:      <DisplayRules>

      69:        <DisplayRule Id="Mscrm.CanWriteOpportunity" />

      70:      </DisplayRules>

      71:      <Actions />

      72:    </CommandDefinition>

      73:    

  7. Add the below Tabrules to display the tab in the Form context, Subgrid context, Subgrid context when showing in the associated view as well
  8.    1: <TabDisplayRule TabCommand="Sample.SubGrid.opportunity.CustomTab">

       2:             <EntityRule EntityName="opportunity" Context="SubGridStandard" />

       3:             <EntityRule EntityName="opportunity" Context="SubGridAssociated" />

       4:           </TabDisplayRule>

       5:           <TabDisplayRule TabCommand="Sample.Form.opportunity.CustomTab">

       6:             <EntityRule EntityName="opportunity" Context="Form" AppliesTo="PrimaryEntity" />

       7:           </TabDisplayRule>

  9. Now you can zip  and install the solution and you can the buttons appearing in the following places
    1. Entity Grid
    2. Entity Form
    3. Entity SubGrid
    4. on Opportunity Associated view as well
  10. You can Download the complete Solution from here.
Advertisements