Let's see how to customize a ribbon tab in CRM 2011 with a group and a few buttons in it. Remember there are some pitfalls while customizing ribbon tab in CRM 2011. So we are going to crack the nut.
In the following screen shot, please note the following.
1. Tab - Departments 2. Group 1- Marketing 3. Group 2.- Sales 4. Button Legal under Marketing Group 5. Button Public Relations under Marketing under Marketing Group 6. Button Customer under Sales under Sales Group
So obviously the hierarchy is
So our nut is " Place a new tab for Account entity form with groups Marketing (2 buttons) and Sales (1 button)"
Lets have a look at the customization.xml. Our playground is the area under RibbonDiffXml.
To make it more simple, lets have a broad view at 4 main regions.
1. Custom Actions -- Where you could define tab, group ,button etc
2. Command definitions -Where you could define the action on the button or group
3. Rule Definitions-- Show / Hide or Enable Disable rule definitions
4. LocLabels --For Localization of labels.
So first we would have a look at the 1.Custom Actions
Pitfall : Scaling
Scaling is one of the pitfalls. Scaling defines how the groups are presented to the Ribbon. There is a tag called Maxsize which defines largest layout possible for a group. Now the pitfall is, if you have 2 groups you must define 2 Maxsize as shown. Otherwise it would display tab, group but no buttons on it.
Secondly, 2. Command Definitions
Please note the bridge between the Custom Action and Command Definition is Command ID.
While defining a tab, group or button we are defining a Command.
Pitfall: If you define a command for tab, group or button, you should use the same as Command ID in Command definition to define an action.
Now we are into 3rd level , 3. Rule Definitions.
This shows how we could define the display rule for a tab. In our case we would like to display the tab ONLY on the entity form. So the context is Form
Following are possible scope of Context:
Form --For the form ribbon.
HomePageGrid---For the ribbon that is displayed for the list of records that appear in the main application navigation pane.
SubGridStandard --For the ribbon that is displayed for the list of records that appear in a subgrid in a form.
SubGridAssociated ---For the ribbon that is displayed for the list of records that appear in the navigation area of a form.
and thus we reached 4th level which is 4. LocLabels.
This is very simple and its used for Localization of labels. Remember the fact that ID is the link to refer these labels.
For your convenience, the whole code is given below.