CRM 2011 does offer <HideCustomAction> to hide Ribbon Elements including Ribbon tabs. However in some cases we might have to selectively hide Tabs based on several conditions.
In such cases <HideCustomAction> is of less helpful as it globally hides the Ribbon element.
In this Walkthrough I am trying to demonstrate on of such scenario.
Scenario: A CRM Entity form has has Many-To-One relationship with multiple entities. Each of these entities are having Sub-Grid to show CRM entity in List form. Now we wanted to hide Contextual (List) tab for Sub-Grid entity from Main form of some of the entities.
Create a CRM 2011 Solution with entity for which Ribbon in Contextual Tab needs to be hidden. In this case entity name is new_cpvertical
Open ExportRibbonXml for the entity new_cpvertical. You can find this xml at SDK folder samplecodecsclientribbonexportribbonxmlbinDebugExportedRibbonXml. If RibbonXml for your entity is not available you can execute the solution exportribbonxml.sln and create one.
In RibbonXml, locate Tab element with Id as “Mscrm.SubGrid.new_cpvertical.MainTab” and copy entire Tab element with all its decendants.
Open customization.xml file from Solution you exported in Step1, and add Tab element copied in Step 3 under
Note that Location value for CustomAction is same as MainTab id.
Copy Command="Mscrm.SubGrid.new_cpvertical.MainTab" and all the Rules that has been referenced in Command.
Copy <TabDisplayRules> element under <RuleDefinitions> as shown below
Note: TabCommand should be same as CommandDefinition Id used under CommandDefinition
Create a new DisplayRule as shown below
Note: EntityName value is name of the PrimaryEntity where Sub-Grid is placed. Depending upon how many such entities need to be configured you can add Or to it.
Call this DisplayRule in Command ="Mscrm.SubGrid.new_cpvertical.MainTab"
Save the Customization, zip it back to Solution file and Import solution in CRM and Publish the Customization.
Here is how it looks with Contextual Ribbon hidden
With Contextual Ribbon (Note there is a List Tools Ribbon tab)
After hiding Contextual Ribbon (Note there is NO List Tools Ribbon tab)
Hope this helps