Some facts about Business rule in D365 CRM.
Hello Guys,
In our previous blog we have explored business rule. Today we will see some facts about business rules.
Business Rules are used for implementing conditional functionalities like validation and pre-filled. The execution order of the business rule is as below:
1. System JS
2. Custom JS
3. Business Rules.
If one Entity is having more than one Business Rule then order of execution depends on their activation. You can see the Rank of the Business Rule's execution order using Synchronous events execution order editor tool in XRM Toolbox.
Consider a scenario, we have one table named Person as below:
We have created two BR for some validation and prefill as shown below:
The first BR is used to make the Last Name field mandatory and other one is used for setting full name based on first name.
Now login to xrmtoolbox and open Synchronous events execution order editor tool and select Person entity. Expand it and you see the rank of the BR.
Basically BR rank depends on activation. Here we created BLG-Person: Make last name mandatory first and activated first and that's why its execution order is 1.
If you deactivate the first BR and then again activate it. It will change its execution order to 2.
You can also change the rank using tool by clicking in the rank and after that click on Apply updates.
One of the main reason why business rule stop working sometimes is, if any field which is referenced in the business rule has been removed or not added. For example here if we remove last name field from the form, 2nd Business rule will not work.
One of the main advantage of Business Rule over JavaScript is, JS triggers only on load, change and save events. Suppose we are performing excel or csv import to create person record into the CRM and we want the field which should trigger the logic. So here JS will not be applicable. But BR can be applicable. That is the advantage of BR over JS.
As you can see, we have change the scope of the BR to Entity. Now we will try to import the one person record using csv import.
When we try to import csv file, import of the records are getting failed as we have not provided value for last name column in csv.
Now we will add value for last name column and try to import it again.
As you can see, data is imported.
Hope it helps!!!
Comments
Post a Comment