MS CRM 2011 – Hiding a Group of Ribbon on Specific State

Today I come up with another task to only show the button on a group only when the record has already been saved.
After some times reading at the CRM 2011 SDK documentation and some time searching for clue, I found a solution.
Desired Result
desired result2
The above pictures are the desired result. The button should be shown after the record has been saved.

So the changes to the Ribbon XML can be like this:

<RibbonDiffXml>
	<CustomActions>
	  <CustomAction Id="Mscrm.ISV.campaignresponse.CustomGroup.MaxSize.CustomAction" Location="Mscrm.Form.campaignresponse.MainTab.Scaling._children" Sequence="150">
		<CommandUIDefinition>
		  <MaxSize Id="Mscrm.ISV.campaignresponse.CustomGroup.MaxSize" GroupId="Mscrm.ISV.campaignresponse.CustomGroup.Interaction" Sequence="21" Size="LargeLarge" />
		</CommandUIDefinition>
	  </CustomAction>
	  <CustomAction Id="Mscrm.ISV.campaignresponse.CustomGroup.CustomAction" Location="Mscrm.Form.campaignresponse.MainTab.Groups._children" Sequence="115">
		<CommandUIDefinition>
		  <Group Id="Mscrm.ISV.campaignresponse.CustomGroup.Interaction" Command="Mscrm.Enabled" Title="Interaction" Sequence="85" Template="Mscrm.Templates.3.3" >
			<Controls Id="Mscrm.ISV.campaignresponse.CustomGroup.Controls">
			  <Button Id="Mscrm.ISV.campaignresponse.Form.Interaction.Button.AddGuest"
							Command="Mscrm.ISV.campaignresponse.Form.Interaction.Command.AddGuest"
							ToolTipTitle="Tip"
							ToolTipDescription="Add Guest"
							LabelText="Add Guest"
							Alt="Add Guest"
							Image16by16="/_imgs/ribbon/AssignRoles_16.png"
							Image32by32="/_imgs/ribbon/AssignRoles_32.png"
							TemplateAlias="o1" />
			</Controls>
		  </Group>
		</CommandUIDefinition>
	  </CustomAction>			
		</CustomActions>
	<Templates>
	  <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
	</Templates>
	  <CommandDefinitions>
		  <CommandDefinition Id="Mscrm.ISV.campaignresponse.Form.Interaction.Command.AddGuest">
			<EnableRules>
			</EnableRules>
			<DisplayRules>
		  <DisplayRule Id="Mscrm.ISV.campaignresponse.CustomGroup.Interaction" />
		</DisplayRules>
			<Actions>
			  <Url Address="$webresource:pages/addGuests" PassParams="true"/>
			</Actions>
		  </CommandDefinition>
	  </CommandDefinitions>
	<RuleDefinitions>
	  <TabDisplayRules />
	  <DisplayRules>
		<DisplayRule Id="Mscrm.ISV.campaignresponse.CustomGroup.Interaction">
		  <FormStateRule State="Create" InvertResult="true" /> <!-- THIS IS THE TRICK -->
		</DisplayRule>
	  </DisplayRules>
	  <EnableRules />
	</RuleDefinitions>
	<LocLabels />
</RibbonDiffXml>
Advertisements

One thought on “MS CRM 2011 – Hiding a Group of Ribbon on Specific State

  1. I do love the way you have presented this specific situation and it does indeed supply us some fodder for consideration. On the other hand, because of just what I have observed, I just wish as the feed-back stack on that people continue to be on issue and not get started upon a tirade associated with the news of the day. Anyway, thank you for this superb piece and even though I do not concur with it in totality, I value your point of view.

Leave a Reply

Please log in using one of these methods to post your comment:

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