As I prepare for my MB2-716 exam I’m producing a series of blog posts that collectively should help others revising for the MB2-716 Certification. (Microsoft Dynamics 365 customization and Configuration.) This time I will look at business rules.
As you revise I highly recommend you often refer to the skills measured statements to ensure you are deeply aware of all the required knowledge. The statement for business rules is below;
With business rules we can create complex rules that conditionally effect the user experience by allowing us to;
- Offer recommendations to users
- Lock / unlock (enable/disable) fields
- Show error messages
- Set fields to specific values
- Set default values
- Make fields mandatory
- Hide and show fields
Another nice thing about business rules is we can define their scope, so that they can be applied to a specific form, all forms or even operate at an entity level. Business rules represent client-side logic that is applied on the form as the form is opened. Also, additionally, when defined as entity level the business rule logic can be applied at a server level. Meaning server side business rules run client-side and server-side. Entity level rule are triggered as users interact with the form AND they run on the server when a record is created or saved.
Business rules that have a scope of “entity” are supported with editable grids.
You should be aware that all of the fields referenced on a business rule must exist on the form (or editable grid). If we have a business rule that runs on a form that references fields thatare available it simply doesn’t run.
You may have already noticed that we have business rule options on the entity, form and even on fields. When viewing business rules, at an entity level we can see all the business rules. When we view the business rules from a form we’ll see all the rules that apply to that form. And if we view them from a field within a form we’ll see only the business rules which could use or impact that specific field. Meaning the rules are displayed from the perspective that they are being viewed.
Business Rules Scope
There are three options possible for the scope of a business rule;
- Single Form Scope – Use this when a business rule specifically applies to a single form. It involves selecting a specific form name.
- All Forms – Use this to apply the business rule to all forms. (Including main and quick create forms.)
- Entity – Use this to run the business rule at a form and server level. (Server level being triggered by a create or update of data.) Useful if the rule is to be applied not only on forms but when data is imported. Also useful if the business rule is to be applied to editable grids.
Tip: To change the scope on an active business rule, you will need to deactivate it before making the change. (Or any change to an active rule for that matter!)
Business Rule Designer
The introduction of Dynamics 365 gave us a new form designed for business rules. Meaning we can create business rules using a drop and drag interface. The designer also gives a graphical representation of business rules that help to make them easy to understand.
When the new designer was first launched I created a blog post to describe this new feature. You may find that post useful. (It also describes the recommendations feature!) You can view that post here.
Part of your revision should include getting some hands-on experience of the business rule designer, so that you become familiar with its key features. Including the minim map and text view features.
Business Rules Example
The best way to explain business rules might be to show a quick example. Below you can see an example of a business rule.
All business rules will have at least one condition. But as you can see we can add more if required. Meaning you can create if, else if and else constructs.
Note: There is a limit of 10 if-else conditions on business rules.
Linked to each result of the condition you can add a number of actions. (or other conditions.) As already mentioned these actions can be used to hide fields, set field values etc.
When considering conditions in business rules it is important to be aware that a condition can have several parts and they can have and / or logic applied. (The default being and.)
The rule above has two conditions based on the relationship type with the account. If the account is a customer that I make the price list mandatory, and default the category and payment terms fields. For suppliers we do different things. Etc. Below you can see that because this account has been set to scustomer then the price list is mandatory, and payment terms / category has been given specific values.
Having created and saved your business rule, you will need to ensure it is activated. Once activated you need to deactivate the business rule to change it.
Each action has slightly different parameters. With set field, for example, you pick the field and then opt to set it to a value or another field. The best approach to learn how the different actions work will definitely be to try some out to see what happens.
I hope this post has given you a feel for how business rules work and some of the core concepts you’ll need to cover for the MB2-716 exam. As always, this is an important area to get some hands-on experience of.