In Microsoft Dynamics CRM 2011, you have the option to customize the ribbon and create rules for any buttons that you add. If you don’t want to use out-of-the-box rules, you can add your own custom rule using JavaScript.


After you create a custom ribbon button and add a rule, you can define the rule as a custom rule. Here’s how:

  1. First make sure that the entity with the ribbon button is in the solution that you want to work with.

    Custom Rules for Ribbon Buttons in CRM 2011

  2. Now create a JavaScript file to make the custom rule. The code will return true or false to answer the condition.

  3. Export the solution and mark the customization when you export it.

  4. Now you can extract the customization.xml file that exist inside the solution.

  5. Modify the code as follows to enable the rule in the CommandDefinition. Point to the Id of the rule. The rule itself is under RuleDefinitions.


  6. Finally, copy the file and reimport it.

There you have it—a simple guide to using JavaScript to create custom rules for ribbon buttons in CRM 2011!

If you want more information on customizing the ribbon in Microsoft Dynamics CRM 2011, check out our blogs on how to hide a ribbon button or our general guide on ribbon customization.

Happy CRM’ing!

Avatar for Joe D365

Joe D365

Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.