Business rules allow you to apply logic to common business scenarios. They provide a simple interface to implement and maintain fast-changing and commonly used rules. A business rule will run in real-time, so you will see the action as soon as a condition has been met. Using Power Apps, you can create business rules for tables in your environment.
By combining conditions and actions, you can do any of the following with business rules:
- Set column values
- Clear column values
- Set column requirement levels
- Show or hide columns
- Enable or disable columns
- Validata data and show error messages
- Create business recommendations based on business intelligence
Bring in the Components for the Solution
Before you can create a business rule, you first need to create a solution and bring in the appropriate components.
- Select the Solutions tab. Then select the Solution for these changes.
- From the menu ribbon, select Add Existing > Table.
- Select the Table for the business rule you are creating.
- Click Next > Add.
- In the solution, select the Table you added for the business rule.
- Select the Business Rules tab.
- Select Add business rule. The Business Rule Designer will open.
Business Rule Designer
The Business Rule Designer provides a simple drag-and-drop interface to implement commonly used business scenarios that used to require custom code.
Name the Business Rule
In the upper-left corner of the window, select the drop-down arrow next to the default business rule name. Give your business rule a unique name and, if needed, add a description to the description box.
Set the Scope
The scope of the business rule determines where it is applied. Set the scope of the business rule, according to the following:
- Entity: All forms for that table, or entity.
- Specific Form: Just the form that you select.
Add Conditions to Business Rule
A condition is an expression that returns true or false. If the expression evaluates to true, the business rule runs. If the condition evaluates to false, the business rule does not run. The Business Rule Designer will open with a single condition already created for you. Every rule starts with a condition. The business rule takes one or more actions based on that condition.
Add Additional Conditions
To add more conditions to your business rule, drag the Condition component from the Components tab to a plus sign in the designer window.
Set Condition Properties
You need to set condition properties to define what triggers the business rule.
- Click the Condition component in the designer window.
- Select the Properties tab on the right side of the screen. Set the properties for that condition. As you set properties, an expression is created at the bottom of the Properties tab.
- Click Apply.
Add Additional Clauses to Condition
You can add additional AND or OR clauses to a condition to further define what triggers the business rule.
- Click +New in the Properties tab to create a new rule. Set the properties for that rule.
- In the Rule Logic field, specify whether to add the new rule as an AN or an OR clause.
- Click Apply.
Note: Business rules don't work with multi-select option sets.
Add Actions to Business Rule Conditions
Actions define what happens in the business rule when a condition is or is not met.
- Select the Components tab.
- Drag an Action component to a plus sign next to the Condition component.
- Drag the action to a plus sign next to a checkmark if you want the business rule to take that action when the condition is met.
- Drag the action to a plus sign next to an x if you want the business rule to take that action when the condition is not met.
- Click the Action component in the designer window.
- Select the Properties tab. Set the properties for that action.
- Click Apply.
Publish a Business Rule
In order for a business rule to become active in your environment, you must validate, save, and activate it.
- Click Validate on the action bar.
- If the business rule runs without any errors, you will receive a success message.
- If errors are found in the business rule, you will receive a fail message.
- To save the business rule, click Save on the action bar.
- To activate the business rule, select Activate in the action bar. The business rule is now active in your environment.
Edit Business Rules
In addition to creating new business rules, you can also edit existing business rules.
- Select the Solutions tab. Then select the Solution for these changes.
- From the menu ribbon, select Add Existing > Table. Select the Table for the business rule you are editing.
- Click Select Components from the Selected Tables list.
- Select the Business rules tab. Then select the business rule that you want to customize.
- Click Add. Once you've added all of your Components, click Add.
- In the solution, select the Table you added for the business rule you are editing.
- Select the Business Rule tab. Select the business rule you added to customize. The Business Rule Designer will open.
- Click Deactivate. If you want to modify an existing business rule, you must deactivate it before you can make changes.
- Once you've made your changes, click Validate > Save > Activate.