In this post I provide a quick guide on how to apply Display Rules to your custom ribbon buttons in Microsoft CRM 2011.
Firstly, here’s a quick run through on how to apply a Display Rule.
I have added a custom button to the Campaign form’s ribbon, as per below:
To add a display rule to limit when the button should appear I need to do 2 things:
1. Define the Display Rule
2. Assign the Display Rule to the button
To define the Display Rule we need to add the following to our customization.xml file:
This can be read as:
“I want to define a new display rule called "GT.campaign.Form.Star.FormStateNotCreate.DisplayRule". The rule is the button should only show if the form is not the Create form”.
And then to assign this rule to our button we simply reference the above ID in the Command Definition of our button:
Here’s a few more common Display Rule examples:
Display only on Create form:
<DisplayRule Id="GT.campaign.Form.Star.FormStateCreate.DisplayRule"> <FormStateRule State="Create" /> </DisplayRule>
Display only on Update or Create form:
<DisplayRule Id="GT.campaign.Form.Star.FormStateCreateOrUpdate.DisplayRule"> <OrRule> <Or> <FormStateRule State="Existing"/> </Or> <Or> <FormStateRule State="Create"/> </Or> </OrRule> </DisplayRule>
Do NOT display when Offline:
<DisplayRule Id="GT.campaign.Form.Star.IsOffLine.DisplayRule"> <CrmOfflineAccessStateRule Default="true" State="Online" /> </DisplayRule>