Setting up business process logic
For every business process, there is always a step-by-step procedure that defines every requirement, objective, and resolution from start to end. Companies build on and improve these procedures depending on the business needs, and they even create departments to work exclusively on this.
Explanation and overview
Model-driven apps help set up these rules by providing several tools to define business logic on various platform levels. You can incorporate data validation rules and structured data flows to guide the end user, and even trigger workflows for defined events on your processes. These are just some examples of what you can achieve with this platform.
Let's improve our help desk app by adding business logic to the solution we created in the previous recipe:
- Hide or make a column visible depending on the status of a ticket using a business rule. In our case, there is no reason to have the
Customer Validation
column visible unless the case is in theResolved
state. - Guide the ticket processing by making sure the user inputs the required information on each defined step with the help of a business process flow (BPF). This component also allows you to execute processes, Power Automate cloud flows, or workflows when a defined trigger gets fired.
How to do it…
- First, open the help desk solution, and let's start by adding data validation rules to the
Tickets
table. Select the table and then click on Edit. - Go to the Business rules tab, and on the toolbar, click on Add business rule; this will open a designer where you can define actions based on a condition.
- Select the default condition, New condition, and on the right panel, set these properties:
Display Name: Customer validation visibility
Under Rules, set to check when
Ticket Status
equalsResolved
orClosed
, and then click on Apply. - Click on Add on the main toolbar to include an Add Set Visibility action. Once you choose this option, two plus signs will appear next to the condition, when it is valid (checkmark) and another when it isn't (X). Place one on the checkmark and then add another for the X.
- Select each new action and set the following properties on the right pane, and then click on Apply:
- Condition is met:
Display Name:
Show Customer Validation
Field:
Customer Validation
Visible:
Yes
- Condition isn't met:
Display Name:
Hide Customer Validation
Field:
Customer Validation
Visible:
No
- Condition is met:
- Finally, click on Ticket: New business rule, located at the upper left of the screen, to set the business rule's name. Enter
Customer validation visibility
and then hit Save on the toolbar, and then on Activate to make it available for this table: - Now, let's create a BPF to guide our users during the ticket processing:
- From your solution, click on the ellipsis on the toolbar and select Switch to classic. This process still requires the classic interface to use the proper solution prefix for the BPF.
- Once the classic solution designer opens, click on Processes on the left pane and then click New in the toolbar; this will open a new dialog to gather properties for your BPF. Set the following values for the
Ticket
table and click OK:
- Once the designer opens, you will find a default stage. These are the steps of your guided flow. Let's create three more stages by dragging them next to each other from the components panel. Click on each one and set Display Name to the following:
New
,In Progress
,Resolved
, andClosed
. For each one, click on Apply afterward. - Each stage comes with a data step by default, which lets us specify the column that gets displayed in each step of our BPF, as well as, most importantly, which ones are required when moving from one stage to the other. Let's configure the data steps for each stage by clicking on Details and setting these values:
New
:Data Field: Description
In Progress
:Data Field: Description – Required
Resolved
:Data Field: Resolution – Required
Closed
:Data Field: Customer validation – Required
- After completing these changes, on the top toolbar, click on Validate to check everything is correct, and then click Save. Finally, click on Activate to enable this BPF.
How it works…
Once we have configured the business process logic for Tickets
, every time this table gets invoked, it will carry on these defined components. To see them working, go to your solution, select the model-driven app, and click on Play; this will open the app on the Pending Tickets
view. Click on New to add a ticket.
You will see that the form now includes your BPF, which lets you have a clear visualization of which step of the process your ticket is. After saving it, if you try to move beyond the Resolved
stage, it will ask you to set the value for the required columns:
As for the business rule, the Customer Validation
column will remain hidden until the ticket status gets changed to Resolved
. Once we enter this column's data, it is then that we can finish the BPF: