When creating a business rule, choosing the scope should be carefully considered. The Business Rule Scope gives the administrator/citizen developer the ability to determine when the business rule will be applied.
There are three options for Business Rule Scope:
- A specific form
- All forms
Both the Specific Form and All Forms options will apply the rule on the client side, meaning these rules are applied when the user has navigated to the form.
Entity however is applied server side, meaning the rule is applied on the database and will be in place in all types of transactions, including plugins, integration jobs, and workflows.
Here is an example business rule on the account record that shows an error message if the zip code is blank:
The business rule has one condition:
If Address 1 Zip Code does not contain any Data
and one Action:
Show error message “Please populate the zip code field”
The goal of this business rule is to prompt the user to populate the zip code field if there is no data in the field.
Based on this scenario, when this Business Rule is applied it will alter based on how you define the scope.
We have two options for client side, a specific form, or all forms. If your environment uses multiple account forms, you must consider which fields are and are not on the form and if there any specific business rules that are applied to those forms.
For example, if you set the scope of this rule to All Forms and you had a specific form that had a business rule to lock the address fields, this could cause a scenario in which the Zip Code field is blank and locked. Both rules applied together will not let the user save any changes on the form, because the example business rule is raising an error because the zip code is blank. The user cannot modify the field because the rule applied on the form is locking the field.
On the other hand, setting the scope to Entity would make the rule apply to all forms and other all transactions, the rule could impact a workflow or integration job. For example, this rule could impact Lead qualification if the scope was set to Entity. If the zip code is not required and left blank on the lead and the user attempts to qualify the lead, this business rule will be applied when the account record is created. Since this rule will preclude the user from saving the record without populating the zip code field, that same rule will apply to the lead qualification system process causing an error and the lead qualification to fail.
Overall, the impact of the business rule scope needs to be considered when developing business rules to ensure the rule is applied correctly throughout all types of CRM transactions.
At the end of the day, scope is about when you’re wanting the business rule to be applied without code. You should carefully consider your existing environment for any potential dependencies that may be affected by the rule, and make sure to test!
Be sure to subscribe to our blog for more Dynamics 365 tips and tricks!
Happy Dynamics 365’ing!