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.


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>