In our previous blog, we described the new features added in Business Rule in CRM 2015. We worked on new server side support in Business rule in detail. This blog will illustrate the new server side Business Rule in detail with the help of example.

Suppose for example, we have a workflow which creates “Contact” for an “Account” every time a new “Account” is created and on the “Contact” entity we have activated a Business Rule which restricts us from entering “Mumbai” as the “City” of the “Contact”.

In the above scenario if we execute the workflow In CRM 2013, it will create the “Contact” and we will get a warning on the “City” field only when we open the “Contact Form” but in CRM 2015 we have got this new feature of server side Business Rules which rolls back the message being fired on the parent entity if the Business Rule is violated at the child entity.

In order to test this new feature of CRM 2015, we have to follow the below steps:

  • Step I: Create a workflow to create a Contact on creation of an Account:

We will create a Real-time workflow which creates a Contact on creation of an Account as shown below:

Real-time workflow creates Contact on creation of Account

  • Step II: Set the Scope of the Business Rule

The screenshot below shows how to set the scope of a Business rule and its value should be set to “Entity” to make business rule to run at server side:

Setting the Scope of Business Rule

  • Step III: Set the conditions and error message 

Once the scope is set for the Business Rule, we set the conditions and message to be shown if the conditions are violated.

Conditions for the Business Rule

  • Step IV: Test the functionality

After setting the Scope of the Business Rule and activating it, we go on the “Account Form” and try to create a new record with “City” is “Mumbai” as shown in the screenshot below:

Account Form

And here we can see that neither the “Account” is created nor the “Contact” if we try to violate the Business Rule, as shown below:

Error on Business Rule violation

Conclusion:

In the new version of CRM we observed that the server side Business Rule acts as plug-in/workflows and it can rollback as a workflow/plug-in if server side business rule throws an error.

Hope this helps!