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:
- 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:
Trigger the workflow from a record and get below error message immediately:
The record cannot be saved due to “Business Process Error”:
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:
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
Pingback: MS CRM 2015 | Roman's Blog