Dynamics CRM 2015 Business Rules – Are you ready?

Dynamics CRM 2015 – Scope of Business Rules

Business Rules was introduced in Dynamics CRM 2013 which was restricted to client side only. Now with  latest CRM 2015, server side business rule is available which will help business user easily configure validation logic and reduce the development effort.

There are three levels of scope:

Scope Where it runs run
Entity All forms and server
All forms All forms
Specific form Just that form

 

In the top right of the form, use the Scope field to set the scope for the rule. “Entity” scope level is new in CRM 2015. Setting the scope of the business rule at an entity level, forces the business rule executed on both server and all clients side.

 

For example, on update of an entity record we will set “Description” field mandatory based on some conditions. So in this case we can create Business rule as below:

Business Rules #1

Business Rules #1

  • Server Side Validation

 

To test this business rule validation on server side, we create a real time workflow to update this record which should trigger the validation logic:

crm 2015 bpa2

Trigger the workflow from a record and get below error message immediately:

crm 2015 bpa3

The record cannot be saved due to “Business Process Error”:

crm 2015 bpa4

Download log file and we can find the trace details:

 

<TraceText>

[Microsoft.Crm.ObjectModel: Microsoft.Crm.ObjectModel.SyncWorkflowExecutionPlugin]

[1769c1b5-1784-e411-80c5-00155d016814: ] Starting sync workflow ‘Test Scope of Business Rule’, Id: 0e69c1b5-1784-e411-80c5-00155d016814

Entering UpdateStep1_step: Sync workflow ‘Test Scope of Business Rule’ terminated with error ‘Attribute ‘new_description’ cannot be NULL’

</TraceText>

 

  • Client Side Validation To test this business rule in client side, we just simply update the record on the form and the error message show up as expected:

 

crm 2015 bpa5

Conclusion:

 

To implement the same validation logic in previous CRM version, we have to develop plug-in in server side. Now CRM 2015 offers us a much simple way to apply the same logic on both server and all clients without writing coding. You can also set the rule select a specific form.

I hope you find it useful!

Author: Zhe Chen
Title: Lead Dynamics CRM Consultant @ Adisys
Email: zhechen@adisys.co

Advertisements