Ribbon Customization Part 12:Custom Ribbon Tab in CRM is now always selected

Usually when we add a custom tab to the HomePageGrid as discussed in the post  , it will add the custom tab but when navigate to different entities , All the times, Custom Tab is selected, in order to avoid that we need add the below TabDisplayRule

<TabDisplayRules>

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

          <EntityRule Context ="HomePageGrid" AppliesTo ="SelectedEntity"/>

      </TabDisplayRule>

</TabDisplayRules>

 

That’s it.,by this You can avoid the default selection of the custom Tab all the times.

Ribbon Customization Part 11:Enable,Disable Ribbon button based on Security Role

After  a small gap I am blogging again, as I have there  there is a requirement for the ribbon controls to he shown depending on the security role.

So in this post I am  going to show a  custom button, in the Case homepage grid  under the Actions group. and I will make this button to be enabled only when the user with the “System Admin”role has logged in and I don’t enable this button for the rest of the users. << and also this button has the functionality for the Resolve Case>>

Steps to follow

  1. Create a solution
  2. Add  the entity ‘case’
  3. Add a Javascript webresource with the following code and named as ‘CommonLibrabry’
  4. function UserHasRole(roleName) {

     

        var serverUrl = Xrm.Page.context.getServerUrl();

        var oDataEndpointUrl = serverUrl + "/XRMServices/2011/OrganizationData.svc/";

        oDataEndpointUrl += "RoleSet?$top=1&$filter=Name eq '" + roleName + "'";

        var service = GetRequestObject();

        if (service != null) {

            service.open("GET", oDataEndpointUrl, false);

            service.setRequestHeader("X-Requested-Width", "XMLHttpRequest");

            service.setRequestHeader("Accept", "application/json, text/javascript, */*");

            service.send(null);

            var requestResults = eval('(' + service.responseText + ')').d;

            if (requestResults != null && requestResults.results.length == 1) {

                var role = requestResults.results[0]; 

                var id = role.RoleId;

                var currentUserRoles = Xrm.Page.context.getUserRoles();

                for (var i = 0; i < currentUserRoles.length; i++) {

                    var userRole = currentUserRoles[i];

                    if (GuidsAreEqual(userRole, id)) {

                        return true;

                    }

                }

            }

        }

     

        return false;

    }

     

    function GetRequestObject() {

        if (window.XMLHttpRequest) {

            return new window.XMLHttpRequest;

        }

        else {

            try {

                return new ActiveXObject("MSXML2.XMLHTTP.3.0");

            }

            catch (ex) {

                return null;

            }

        }

    }

    function GuidsAreEqual(guid1, guid2) {

        var isEqual = false;

        if (guid1 == null || guid2 == null) {

            isEqual = false;

        }

        else {

            isEqual = guid1.replace(/[{}]/g, "").toLowerCase() == guid2.replace(/[{}]/g, "").toLowerCase();

        }

     

        return isEqual;

    }

     

    function callMain() {

     

    if(UserHasRole("System Administrator"))

    {

    return true;

    }

    else 

    {

    return false;

    }

     

    }

  5. Export the solution
  6. Unzip the solution
  7. Edit the customization
  8. Add the below custom action to display the button under the –Actions Group in the HomepageGrid
  9. <CustomAction Id ="sample.HomepageGrid.incident.MainTab.Actions.CustomAction" 

    Location ="Mscrm.HomepageGrid.incident.MainTab.Actions.Controls._children" 

                           Sequence ="10">

              <CommandUIDefinition>           

                  <Button Id="sample.HomepageGrid.incident.MainTab.Actions.Button"

                          Command="sample.HomepageGrid.incident.MainTab.Actions.Command"

                          LabelText="$LocLabels:sample.HomepageGrid.incident.MainTab.Actions.LabelText"

                          ToolTipTitle="$LocLabels:sample.HomepageGrid.incident.MainTab.Actions.LabelText"

                          ToolTipDescription="$LocLabels:sample.HomepageGrid.incident.MainTab.Actions.ToolTip"

                          TemplateAlias="o1"

                          Image16by16="/_imgs/ribbon/AddEmail_16.png"

                          Image32by32="/_imgs/ribbon/Email_32.png" />             

              </CommandUIDefinition>         

            </CustomAction>

  10. Define the command definition., basically this button has the functionality of << Resolving a case>>
    1. this will enable when only one record is selected in the Grid and also if the user has the ‘System Administrator” Role
    2. <CommandDefinition Id="sample.HomepageGrid.incident.MainTab.Actions.Command">

                 <EnableRules>

                   <EnableRule Id="Mscrm.CustomcheckRole" />

                   <EnableRule Id="Mscrm.SelectionCountExactlyOne" />             

                   <EnableRule Id="Mscrm.VisualizationPaneNotMaximized" />

                 </EnableRules>

                 <DisplayRules>

                   <DisplayRule Id="Mscrm.CanChangeIncidentForm" />

                 </DisplayRules>

                 <Actions>

                   <JavaScriptFunction FunctionName="Mscrm.IncidentActions.resolveCase" Library="/_static/_common/scripts/ribbonactions.js">

                     <CrmParameter Value="FirstSelectedItemId" />

                     <CrmParameter Value="SelectedControl" />

                   </JavaScriptFunction>

                 </Actions>

               </CommandDefinition>

  11. Provide the appropriate Display rule as well as the Enable rules as shown below
  12. <DisplayRules>

               <DisplayRule Id="Mscrm.CanChangeIncidentForm">

                 <EntityPrivilegeRule EntityName="incident" PrivilegeType="Write" PrivilegeDepth="Basic" />

                 <EntityPrivilegeRule EntityName="incident" PrivilegeType="AppendTo" PrivilegeDepth="Basic" />

                 <EntityPrivilegeRule EntityName="activitypointer" PrivilegeType="Create" PrivilegeDepth="Basic" />

                 <EntityPrivilegeRule EntityName="activitypointer" PrivilegeType="Append" PrivilegeDepth="Basic" />

               </DisplayRule>            

             </DisplayRules>

             <EnableRules>

               <EnableRule Id="Mscrm.SelectionCountExactlyOne">

                 <SelectionCountRule Minimum="1" Maximum="1" AppliesTo="SelectedEntity" />

               </EnableRule>

               <EnableRule Id="Mscrm.VisualizationPaneNotMaximized">

                 <CustomRule FunctionName="Mscrm.RibbonActions.disableButtonsWhenChartMaximized"

             Library="/_static/_common/scripts/RibbonActions.js">

                   <CrmParameter Value="SelectedControl" />

                 </CustomRule>

               </EnableRule>

               <EnableRule Id="Mscrm.CustomcheckRole">

                 <CustomRule FunctionName="callMain"

     Library="$webresource:new_CommonLibrary">

                 </CustomRule>

               </EnableRule>

             </EnableRules>

  13. Provide the locales as shown below
  14. <LocLabels>

             <LocLabel Id="sample.HomepageGrid.incident.MainTab.Actions.LabelText">

               <Titles>

                 <Title languagecode="1033"

                         description="Custom Button1" />

               </Titles>

             </LocLabel>

             <LocLabel Id="sample.HomepageGrid.incident.MainTab.Actions.ToolTip">

               <Titles>

                 <Title languagecode="1033"

                         description="Custom Button1" />

               </Titles>

             </LocLabel>

           </LocLabels>

  15. The screenshot appears as  shown below. when I logged with a user having system Admin role
  16. EnableRibbon button based on securityrole_CRM2011
  17. The screenshot appears as  shown below. when I logged with a user who doesn’t have system Admin role
  18. disable ribbon button based on security Role_CRM 2011
  19. The entire source code can be downloaded from here
  20. Happy learning Smile

Ribbon Customization Part-10-Hide ‘Add Existing’ button in Dynamics CRM 2011

To day we will see how to hid the ‘Add existing’ button on the Contact Associated view on the Account Entity. (Hiding Add Existing button was a very popular requirement in CRM 4.0)

When you open an Account entity record and click on ‘Contacts’ in the left navigation bar of the entity. you can see’Add New Contact’ and ‘Add Existing Contact’ buttons. Today we will see how to hide them using the Ribbon Customization

Follow the bellow steps

  1. Create a Solution ‘Add Contact entity
  2. Export the solution
  3. Unzip and Edit the Customizations.xml file
  4. Now we need to fine the Id of the ‘Add Existing’,Add New’ Buttons  For this I opened the ‘contactribbon.xml’ which is available under ..\\sdk\samplecode\cs\client\ribbon\exportribbonxml\exportedribbonxml( this location depends on the Sdk installation directory  on the file system)
  5. I found the ids as shown  below from the contactribbon.xml
  6. ContactRibbon
  7. Add  the below code  in the RibbonDiffXML
  8.    1: <CustomActions>

       2:          <HideCustomAction Location="Mscrm.SubGrid.contact.AddNewStandard" HideActionId="sample.Mscrm.SubGrid.contact.AddNewStandard.HideAction" />

       3:          <HideCustomAction Location="Mscrm.SubGrid.contact.AddExistingAssoc" HideActionId="sample.Mscrm.SubGrid.contact.AddExistingAssoc.HideAction" />

       4:          <HideCustomAction Location="Mscrm.SubGrid.contact.AddExistingStandard" HideActionId="sample.Mscrm.SubGrid.contact.AddExistingStandard.HideAction" />

       5:        </CustomActions>

  9. Save it, Zip it and Import the Solution
  10. Refresh the browser the screenshot looks like below
  11. Hide Add Exisitng Buttons
  12. Download the entire solution from here.

Ribbon Customization Part-8-Hiding a Group of Ribbon Buttons in Dynamics CRM 2011

In my earlier post we have seen how to hide a ribbon button , In this post we will see how to hide the  group of buttons in the Ribbon

Now we will try to hide the “Actions”group in the Opportunity entity ribbon. see the below screenshot  which displays the Ribbon on the opportunity entity

ExistingRibbonOnOpportunityEntity

We are going to hide the entire “Actions” group

Steps to Follow

  1. We need to find the Id of the Ribbon component i.t “Actions”Group
  2. We need to open the “opportunityribbon.xml” which will be available at   “sdk\samplecode\cs\client\ribbon\exportribbonxml” 
  3. Open the “Opportuniyribbon.xml” find the “Actions”Group id as shown in the below screenshot
  4. finding the GroupId in Opprotunityribbonxml
  5. Now we need to create a new Solution
  6. Add the Opportunity Entity
  7. Save  and export the Solution
  8. Unzip the Solution
  9. Edit the “Customizations.xml”
  10. Go to the <<RibbonDiffXML>>
  11. Add the below  <<HideAction>> under the<<CustomActions>>under the <<RibbonDiffXML>>
  12.    1: <!-- to hide the Actions Group on the HomepageGrid Ribbon -->

       2:          <HideCustomAction Location="Mscrm.HomepageGrid.opportunity.MainTab.Actions" 

       3:                            HideActionId="Mscrm.HomepageGrid.opportunity.MainTab.Actions.HideAction" />

       4:          <!-- to hide the Actions Group on the Entity Form Ribbon -->

       5:                                     

       6:          <HideCustomAction Location="Mscrm.Form.opportunity.MainTab.Actions" 

       7:                            HideActionId="Mscrm.Form.opportunity.MainTab.Actions.HideAction" />

  13. Save  the File
  14. ReZip
  15. Import and Publish the Solution
  16. Refresh the Browser and you can see the Opportunity Entity ribbon looks like the below screenshot
  17. Hiding a Group of buttons in CRM2011 Ribbon
  18. That’s it for now.. Happy learning Smile
  19. Download the Complete Solution from here

Ribbon Customization Part-7-Hiding a Ribbon Button in Dynamics CRM 2011

In this Post we will see  how to hide the CRM 2011 ribbon button , for this  I will take opportunity Entity and try to Hide the “Send Direct Email”Button which appear on the Home page grid of the Opportunity entity.

Steps to Follow

  1. Create a New Solution  ,Add the Opportunity entity
  2. Save and Export the solution
  3. Unzip the solution and edit the “customizations.xml” using visual studio 2010
  4. Here we need to find the Id of the “Send Direct Email” Button for that I would open the “Opportunityribbon.xml” available in “\\sdk\samplecode\cs\client\ribbon\exportribbonxml\exportedribbonxml” (this location depends on where you downloaded the Dynamics CRM 2011 SDK)
  5. and I found the  Id of the button as “Mscrm.HomepageGrid.opportunity.SendDirectEmail”
  6. Add the below code to  hide the button under the <<CustomActions>> under the <<RibbonDiffXML>>
  7.    1: <HideCustomAction Location="Mscrm.HomepageGrid.opportunity.SendDirectEmail"

       2:                 HideActionId="Mscrm.HomepageGrid.opportunity.SendDirectEmail.HideAction" />   

  8. Save
  9. Rezip
  10. Import and publish
  11. Refresh the browser you can see the  the “Send Direct Email Button” won’t be displayed
  12. Down load the complete solution from here

Ribbon Customization-Part 3-Add a Custom Tab to a Specific Entity(Opportunity Entity)

In this post we will see how to add a custom tab to specific entity. I am choosing to add a Custom Tab with name “myCustomTab” to the “Opportunity” Entity

  1. Create a new solution and add the opportunity entity  save and export the solution
  2. Unzip the solution and open the customization file in visual studio
  3. Make sure that you enable the Intellisense  for visual studio 2010 to edit the xml files as discussed in my earlier post
  4. AS the customization file consists of the entire entity we need to find out where the RibbonDiffXML. you can see <RibbonDiffXml> by minimizing the <FormXml> as shown in the below screenshot

 Oppotunity-Adding a Custom Tab Dynamics CRM 2011

5.       To understand  the structure of the Ribbon available for Opportunity entity SDK has given  all entity ribbon xmls  and you can find out at sdk\samplecode\cs\client\ribbon\exportribbonxml\exportedribbonxml\    and you can select the “opportunityribbon.xml” in the Visual studio.

6.        Understand how the existing tabs has been created in the “opportunityribbon.xml” and refer my earlier posts for better understanding on Ribbon customization.

  1.  
    1. MS Dynamics CRM 2011 :Ribbon Customization Part-1-Add a custom tab to Microsoft Dynamics CRM 2011 ribbon
    2. MS Dynamics CRM 2011 :Ribbon Customization Part-2-Understanding the Ribbon customization

7.        The <RibbonDiffXml> in the Opportunity entity appears as below

   <RibbonDiffXml>

        <CustomActions>

          <CustomAction Id =”Mscrm.Isv.GlobalCustomAction” Location=”Mscrm.Tabs._children” Sequence=”500″ Title=”myCustomAction” >

            <CommandUIDefinition>

              <Tab Id=”Mscrm.HomepageGrid.opportunity.CustomTab” Command=”Mscrm.HomepageGrid.opportunity.CustomTab” Title=”myCustomTab” Description=”myCustomTab” Sequence=”300″>

                <Scaling Id=”Mscrm.HomepageGrid.opportunity.CustomTab.Scaling”>

                  <MaxSize Id=”Mscrm.HomepageGrid.opportunity.CustomTab.CustomGroup.MaxSize” GroupId=”Mscrm.HomepageGrid.opportunity.CustomTab.CustomGroup” Sequence=”20″ Size=”LargeMedium” />

                  <Scale Id=”Mscrm.HomepageGrid.opportunity.CustomTab.CustomGroup.Scale.1″ GroupId=”Mscrm.HomepageGrid.opportunity.CustomTab.CustomGroup” Sequence=”120″ Size=”LargeSmall” />

                  </Scaling>

                <Groups Id=”Mscrm.HomepageGrid.opportunity.CustomTab.Groups”>

                </Groups>

              </Tab>            

            </CommandUIDefinition>                     

          </CustomAction>         

        </CustomActions>

         <Templates>

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

        </Templates>

        <CommandDefinitions/>        

        <RuleDefinitions>

          <TabDisplayRules>

            <TabDisplayRule TabCommand =”Mscrm.HomepageGrid.opportunity.CustomTab” >

              <EntityRule AppliesTo =”SelectedEntity”  EntityName =”opportunity” Context =”HomePageGrid”/>

            </TabDisplayRule>

          </TabDisplayRules>          

          <DisplayRules/>         

          <EnableRules />

        </RuleDefinitions>

        <LocLabels/>       

      </RibbonDiffXml>

      8.        The end Result is as shown in the below screenshot 

      AddingCustomTab toOpportunity-CRM 2011

9.        Download the unmanaged solution from here

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>

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

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)