Microsoft introduced Business Rules in CRM 2013 to provide custom business logic through a simple UI and to eliminate the need to write scripts.
However there were some limitations,
- Business rules in CRM 2013 execute only Client Side.
- Has no if…else if…else support hence need to develop multiple rules to express rich business logic.
What’s new in Dynamics CRM 2015?
With the next version “CRM 2015”, Microsoft has released an update to the Business Rules platform basically to eliminate the limitation in its previous version. With these improvements, it is now very easy to design custom validations and logic through a simple click and point interface.
It has introduced the following enhancements:
- Server side support
Business Rules can now be executed at server side. The new option i.e. “Entity” has added in Scope.
If business rule is created with scope as “Entity” then the business rules will execute server side. This means that you do not need the CRM form for the rules to be executed. It can also be executed when you do updates to a record programmatically similar to the concept of Workflows and Plugins.
So say we programmatically update one field say Amount on an entity and we have a business rule that is set to fire on the change of the Amount field, the business rule will fire and perform the business rule action even though it was not updated through the standard CRM UI.
In this aspect it behaves similar to the Plugins and Workflows. Point to note here though is that Server side Business Rules only run synchronously and the results will be displayed immediately on the record and if done through CRM UI, the results will be available to the user immediately.
- If…else if…else support
Earlier we were only allowed to write an If condition. There was no scope to write the else part for the condition within the same business rule. As a workaround, we had to create another business rule for the else condition. Now you can write if and else within the same business rule.
- And/or support
To take this further, while specifying the conditions, it is now possible to combine conditions using AND or OR. But you can only use one of them in a single condition i.e you still cannot create complex conditions that use a combination of AND and OR conditions.
- Default Values
You must have noticed while adding Optionset field, we are allowed to specify the default value that we would like set for the field. Using business rules you can now set default values for other data types as well. It is similar to the set Value action available, but it differs in the fact that this is only executed for Create operations only. The Set default actions are not supported for any update operation.
For example, on create of opportunity if Topic contains ”Monitor” then set the default value of Budgeted Amount to 6000.
So in this case we can create Business rule as below:
Whenever opportunity is created with Topic containing Monitor word then Budgeted Amount will be set to 6000. On update of Topic it will not work. If while creating we manually enter budget amount to 2000 then it will not be overridden by 6000 upon save. So it only sets the value if no value has been provided as an input. You can set default value without any conditions to make sure the field gets the value specified.
Though these updates definitely take the Business Rule functionality one notch higher, it still leaves room for improvement.
- Complex conditions are still not supported… perhaps asking for too much 🙂
- Still unable to set the value as null for/clear value of a field.
- It only allows for a single If.. Else.. condition. Complex nested if..else is still not supported.
- Unable to update fields of related entity i.e a field of the record that is set as the lookup for the current record (N:1).
Hopefully the next UR may address some of these.