With RibbonDiff you can add a custom button to the ribbon of a sub-grid. You can further add a display rule to only show this button when the sub-grid is being shown within the form of a particular parent entity type. This is achieved by the FormEntityContextRule. Below is an example RibbonDiff XML to add the “Click Me!!” button and to have it shown only when the sub-grid is being displayed on the new_staff form.
<RibbonDiffXml> <CustomActions> <CustomAction Id="new.new_staff.Test1.CustomAction" Location="Mscrm.SubGrid.new_staff.MainTab.Management.Controls._children" Sequence="1"> <CommandUIDefinition> <Button Id="new.new_staff.Test1.Button" Command="new.new_staff.Test1.Command" Image32by32="/_imgs/Ribbon/Entity32_8006.png" Image16by16="/_imgs/Ribbon/Entity16_8006.png" LabelText="Click Me!!" Sequence="1" TemplateAlias="o1"/> </CommandUIDefinition> </CustomAction> </CustomActions> <CommandDefinitions> <CommandDefinition Id="new.new_staff.Test1.Command"> <EnableRules/> <DisplayRules> <DisplayRule Id="new.new_staff.DisplayRule.StaffFormOnly"/> </DisplayRules> <Actions> <JavaScriptFunction FunctionName="isNaN" Library="$webresource:new_staff/staff.js"/> </Actions> </CommandDefinition> </CommandDefinitions> <RuleDefinitions> <TabDisplayRules/> <DisplayRules> <DisplayRule Id="new.new_staff.DisplayRule.StaffFormOnly"> <FormEntityContextRule EntityName="new_staff"/> </DisplayRule> </DisplayRules> <EnableRules/> </RuleDefinitions> </RibbonDiffXml>
By default however this button would then also be shown in Advanced Find results. This is because Advanced Find results is essentially treated as a sub-grid.
Sub-grid on the Staff form:
Advanced Find results:
To hide the button in Advanced Find results, we need to add the Default=”false” attribute to the FormEntityContextRule as below.
<FormEntityContextRule EntityName="new_staff" Default="false"/>
By the way, check out CRMQuickDeploy if you are a CRM ninja that works with RibbonDiff XML directly in Visual Studio and wants to quickly deploy it to CRM.