Pages

Tuesday, August 2, 2011

CRM 2011 EnableRules and DisplayRules

My former post provided a visual overview of adding a button to a CRM 2011 form ribbon. We will now take this one step further by exploring the EnableRules and DisplayRules options. Simply stated these rules control the  enabled/disabled and show/hide behavior of the custom ribbon. This is important because the button may not be always relevant on the form being edited and this provides you with an ability to manage this.

Please refer to the screenshot below.




  1. EnableRules/DisableRules - These should be added to the CommandDefinition section of the customization file. There must also be a corresponding entry in the RulesDefinition section of the customization file.
  2. CommandDefinition EnableRule Id - Add an id here that uniquely identifies the rule that you are adding
  3. CommandDefinition DisplayRule Id - Add an id here that uniquely identifies the display rule that you are adding 
  4. RuleDefinitions EnableRule Id - This should match the EnableRule Id added in step #2.
  5. RuleDefinitions EnableRule CustomRule - This once again references a custom jscript function that will determine whether to enable or disable the button. I chose to reference the "default" contact library but this could be any jscript library.
  6. RuleDefinitions DisplayRule Id - This should match the DisplayRule Id added in step #3. 
  7. RuleDefinitions DisplayRule FormStateRule - This tells the form that the button should only be displayed on "Existing" forms i.e. the update as opposed to the create form.
  8. Function CustomEnableRule - The function in the example above must be created in the relevant jscript library and should match the FunctionName from the CustomRule section
If there were more "involved" considerations for the DisplayRule, we could of course have also created a custom jscript function to allow for greater manipulation of this rule. Refer to the CRM SDK for more configuration options.

No comments:

Post a Comment