How to define Business Rule execution order to avoid conflict

In the context of Microsoft Dynamics CRM, Business Rule is a feature made available since version 2013 that allows power users to easily design, apply and maintain form logic and validation rules without the need to write code. In recent projects, I have seen business rules heavily used in place of JavaScript and plugin code, following the configuration over customisations way of thinking.

A business rule is associated with an entity, and it is not uncommon in projects to have a number of business rules that you want to run in a certain order. For example, you may have the following business rules in Account:

  1. Set Territory, to help set Territory lookup field based on entered Country field (e.g. if Country is “Australia” or “New Zealand”, set Territory to “Australia – New Zealand”).
  2. Check Territory, to check if the Country and Territory values is a valid combination.

Account Form

Unfortunately, despite of various improvements Microsoft has made since the initial release, there isn’t yet a proper way to specify Business Rule execution order in Dynamics CRM. In fact, when you deploy the business rules above, “Check Territory” will execute before “Set Territory”, and potentially result in errors.

A workaround is to manually deactivate these business rules and re-activate them in the correct order, but this is not an ideal approach.

Another more effective workaround I’ve found is to prefix the names with numbers to reflect the execution order, e.g. “01 Set Territory”, and “02 Set Territory”. Although not officially documented, I’ve found that when deployed to another environment, Microsoft Dynamics CRM activates business rules in alphabetical order, so business rules numbered correctly will be executed in the correct order.

Advertisements

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