Changing the Execution Order of Business Rules in Microsoft Dynamics CRM

Note: I originally published this at cobalt.net

Business Rules are a great way to customize form behavior in Microsoft Dynamics CRM. This feature was introduced in CRM 2013 and is now available in CRM Online, CRM 2013 and CRM 2015. With a simple setup, Microsoft has provided a way to set field values, set field requirement levels, show or hide fields, enable or disable fields, validate data and show error messages, all without writing any JavaScript.

With so much functionality available you’re bound to have multiple rules for some entities and if you have inter-related Business Rules it may be important for you to run them in a specific order. Unfortunately Microsoft doesn’t provide a way to specify the order that the rules should be executed, but after some quick research, we found that they run in the order they were activated – oldest first (http://technet.microsoft.com/en-us/library/dn531086.aspx#BKMK_OrderOfLogic).

So, the trick is to deactivate all of the business rules for a specific entity and reactivate them in the order you want them to execute. This works well when you create the rules all at once, but it doesn’t allow you to see what the current order is after the fact. This becomes an issue when adding new rules or troubleshooting.

To work around this limitation, you can simply use Advanced Find (our longtime favorite CRM feature) to find the rules. You can infer the activation date from the Modified On date since you can’t make changes unless you deactivate the rule. Business rules are a type/category of process in CRM, so an advanced find of active process where the primary entity is the entity whose rules you’re reviewing will do the trick.

business_rule_find

Run the query to get back your business rules…

business_rule_find_results

… and get the results.

The other really cool feature is that you can deactivate and edit the business rules directly from the advanced find results! If you sort the view/results by the Modified On date, you can quickly view the execution order.

Leave a Reply

Fill in your details below or click an icon to log in:

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