NOTE
Effective November 2020:
- Common Data Service has been renamed to Microsoft Dataverse. Learn more
- Some terminology in Microsoft Dataverse has been updated. For example, entity is now table and field is now column. Learn more
Lab 02.2: Business Process Flows and Business Rules
In this lab you will enhance the data model and improve the app behavior by adding a business process flow and a business rule.
What you will learn
-
How to identify stages in a Business Process Flow (BPF)
-
How to create and use a BPF
-
How to use a business rule to implement logic
High-level lab steps
-
Exercise 1 – Create BPF lifecycle of problem report
-
Route
-
Fix
-
Resolved
-
-
Exercise 2 – Business rule to not allow close without resolution
Prerequisites
- Must have completed Lab 02.1: Data model and model-driven app
Detailed steps
Exercise 1: Create business process flow
In this exercise, you will create a business process flow for the problem report table.
Task 1: Customize Table
In this task, you will add a lookup Column to the problem report table.
-
Navigate to the Power Apps maker portal page and make sure you are in the correct environment.
-
Select Solutions and click to open the Company 311 solution.
-
Locate and click to open the Problem Report table.
-
Click + New, then click Column.
-
Enter Assign to for Display name, select Lookup for Data type, select User for Related table, and click Save.
-
Select All in the Objects navigation tree.
-
Click Publish all customizations and wait for the publishing to complete.
Task 2: Create business process flow
In this task, you will create a business process flow for the Problem Report table.
-
Navigate to the Power Apps maker portal page and make sure you are in the correct environment.
-
Select Solutions and click to open the Company 311 solution.
-
Click + New > Automation > Process > Business process flow.
- In the New busines process flow panel enter Problem resolution process for Display name, select Problem Report for Table, and click Create.
- Select the New stage, go to the Properties pane, change the Display Name to Route, and click Apply.
- Expand Details of the Route stage.
- Select Data Step #1, go to the Properties pane, select Building for Data Field, and click Apply.
- Click + Add and select Add Data Step.
-
Select the + option to add the data step below the Building data step.
-
Select the new data step, go to the Properties pane, select Location for Data Field, and click Apply.
-
Click + Add again and select Add Data Step.
-
Select the new data step, go to the Properties pane, select Department for Data Field, and click Apply.
-
The Route stage should now look like the image below.
-
Click + Add and select Add Stage.
-
Add the new stage after the Route stage.
-
Select the stage, go to the Properties pane, enter Fix for Display Name, and click Apply.
-
Expand Details of the Fix stage.
-
Select Data Step #1 of the Fix stage.
-
Go to the Properties pane, select Assign to for Data Field and click Apply.
-
Click + Add and select Add Stage.
-
Add the new stage after the Fix stage.
-
Select the new stage, go to the Properties pane, enter Resolve for Display Name and click Apply.
-
Expand Details of the Resolve stage.
-
Select Data Step #1 of the Resolve stage.
-
Go to the Properties pane, select Resolution for Data Field and click Apply.
-
Click + Add and select Add Data Step.
-
Add the new data step below the Resolution data step.
-
Select the new data step, go to the Properties pane, select Resolved on for Date Field and click Apply.
-
The Business process flow should now look like the image below. Click Save.
-
Click Activate.
-
Click Activate again on the pop-up.
-
Confirm that Status: Active on the bottom-left side of the screen.
-
Close the process editor browser window or tab.
-
Click Done.
Exercise 2: Create business rule
In this exercise, you will create a business rule that will block completion of problems without resolution.
Task 1: Create business rule
-
Navigate to the Power Apps maker portal page and make sure you are in the correct environment.
-
Select Solutions and click to open the Company 311 solution.
-
Locate and click to open the Problem Report Table.
-
Select the Business rules tab and click Add business rule.
- Make sure the Scope is set to Entity and click Show details chevron.
- Change Business rule name to Completion rule and click Hide details chev
-
Select the Condition.
-
Go to the Properties pane and change the Display name to Resolution required.
-
Scroll down to Rule 1, select Status Reason for Field, select Equals for Operator, select Value for Type, select Completed for Value, and click Apply.
- Click + New.
- Scroll down to Rule 2, select Resolution for Field, select Does not contain data for Operator, make sure And is selected for Rule Logic, and click Apply.
- Click + Add.
-
Select Add show error message.
-
Add the action on the true path of the condition.
- Select the new action, go to the Properties pane, enter Show message for Display Name, select Status Reason for Field, enter The Problem must have a resolution before it can be closed for Message, and click Apply.
- The business rule should now look like the image below. Click Save.
- Click Activate.
- Click Activate again on the pop-up.
- Confirm activation.
- Close the process editor browser window or tab.
- Click Done.
Exercise 3: Test processes
In this exercise, you will test the business process flow and the business rule you created.
Task 1: Test processes
-
Navigate to the Power Apps maker portal page and make sure you are in the correct environment.
-
Select Apps and click to open the Company 311 Admin application.
-
Select Problem Reports and click + New.
-
You should see the business process flow stages. Enter Dark parking lot for Title, select London Paddington for Building, enter There are no lights at the north end of the parking lot for Details, and click Save.
- Click on the Route stage.
- Enter North-end for Location, select Facility Maintenance for Department and select the Next stage stage.
NOTE
If the Next Stage option is not visible, then refresh the page.
-
Select a user for Assign to and click Next stage.
-
Select date and time for the Resolved on and leave the Resolution value empty.
-
Scroll down to the resolution details section and select Completed for Status Reason. You should see the business rule error message.
- Provide Resolution. The error message should go away.
- Save the Row.