In this article, we are going to learn about Dataverse
Business rules, how to create them, what are the usefulness of the rules, what
are the limitations to use them with model driven app and canvas apps.
What is Business Rule in Dataverse?
In Dataverse, Business Rules are created to apply logic and
validations without writing codes.
Note:
- Business rules are defined on table and are
applied for both model-driven apps and canvas apps if the table is used
within the app.
- If you want to modify existing Business Rule,
then you need to deactivate it first.
- Performance Impact: Power platform
supports up to 150 Business Rules on a table, after that you will start
experiencing performance degradation.
- You can see performance issue when any new or
existing rules are activated (because the table will start running the
rules).
- Business Rules work with most of the data
types like
- Text
- Number
- Choice
- Date
- Image
- Lookup
- Owner
- Business Rules Doesn’t work with data type
like
- Choices (Multi-Select)
- File
- Language
What can you do using Business Rules?
You can achieve following actions using Business Rules.
- Set column values
- Clear column values
- Set column requirement levels
- Show or hide columns (Not available for
canvas apps)
- Enable or disable columns (Not available for
canvas apps)
- Validate data and show error messages
- Create business recommendations based on
business intelligence (Not available for canvas apps)
What are the limitations of Business Rules?
- There is no Exception handling or error
handling mechanism for Business rules.
- We can’t debug or trace business rules.
- Business rules won’t work at the time of Bulk
operations like edits or inserts.
- Only 10 IF – ELSE conditions are
supported in a single Business Rule.
- JavaScript cannot be called from Business
Rules.
- We can’t show/hide tabs or sections from
Business Rules.
- Business Rule will not work if the field
on which the Business Rule is set, is not included on the Form.
How to create Business Rules?
- Go to https://make.powerapps.com/
- Open an already created Dataverse table.
- Click on Business Rules.
- Click on New Business Rule.
- A separate Business Rule window will open with
default condition block already created.
- You need to set the scope first.
- Scope = Entity: This scope will be
applied on Entity (Table or server side) and all the model-driven app
forms.
If you want to use the rule for canvas app, you can select Table
as scope. - Scope = All Forms: This scope will be
applied on all the model-driven app forms.
- Scope = Specific Form (Information): This
scope will be applied to a specific model-driven app form.
Note:- Every Rule starts with a condition and, based on
that you can apply multiple actions on it.
- If you want to edit an existing Business Rule,
then you must first deactivate it.
- You can set the Business Rule name and a
meaningful description from the top bar of the Rule window.
- Now, select the condition block, this will let
you modify the condition from the right-side properties window. Here, we are
setting the condition: If Title column value equals Mr
- If you want to add multiple conditions, you can
do so by clicking on New from the right side of the Rules section.
- Now, let’s place an action, this will fire in
case the above condition is matched. Click on Add (+) from the top navigation,
that will prompt you to choose an action from the list.
- Here, we are setting a field value in case the
above condition is fulfilled.
Action: It will set the field FullName value to President.
- If you want to add more actions for the same
condition, you can again click on Add (+) and follow the above steps to add
actions.
- If you want to perform some action when the
condition is not match (The ELSE Part), you can drag action on the plus
sign at the bottom of the condition as shown in the screenshot.
- The Business rule after adding else part.
- After the completion, you can Validate
and Activate the Business rule.
- Until you activate the rule, it will keep
showing the Status = off so make sure you Activate to use it.
- That’s it. Your Business rule is ready to use.