I am creating a series of blog posts that collectively are designed to help anyone preparing for the Microsoft Dynamics 365 Customer Engagement Core exam. (aka MB-200) In this post I will look at concepts around business rules.
You can see below that we have a section of the exam which covers managing the user experience. Within this section under the heading “Create and manage processes” business rules are mentioned.
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 rules 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 that aren’t available it simply doesn’t run.
We have two methods of accessing business rules for an entity. The newer interface is “make.powerapps.com”. (I recommend you use this one.) But as this is still pretty new we do have a “switch to classic” option that will open the older style app configuration options.
WITHIN THE CLASSIC INTERFACE … we have a business rule options on the entity, form and even on fields. When viewing business rules, at an entity level we 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.
WITHIN THE NEWER maker.powerapps.com INTERFACE … to view, amend and create business rules open the entity. You can see a list of business rules associated with the entity. But when you load the new form editor you do not see business rules. Meaning the rules are now only display at an entity level.
Below you can see that within “make.powerapps.com” I have opened my solution and selected to edit an entity. Within the tabs available for the entity I have business rules.
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.
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 concepts you’ll need to cover for the MB 200 exam. As always, this is an important area to get some hands-on experience of.