How to hide custom sub-grid ribbon button in Advanced Find results [CRM]

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:

1 Sub-Grid on Form

Advanced Find results:

2 Advanced Find

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.

Advertisements

About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in CRM. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s