Book Image

Microsoft Power Apps Cookbook

By : Eickhel Mendoza
Book Image

Microsoft Power Apps Cookbook

By: Eickhel Mendoza

Overview of this book

Microsoft Power Apps Cookbook is a complete resource filled with meticulously crafted recipes to help you build customized business apps that meet ever-changing enterprise demands. You will learn how to design modern apps with the low-code approach in a rapid application development environment by achieving enterprise-wide business agility.
Table of Contents (13 chapters)

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 the Resolved 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…

  1. 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.
  2. 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.
  3. 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 equals Resolved or Closed, and then click on Apply.

  4. 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.
  5. 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

  6. 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:
    Figure 2.13 – Customer validation business rule

    Figure 2.13 – Customer validation business rule

  7. 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:
Figure 2.14 – New BPF dialog

Figure 2.14 – New BPF dialog

  1. 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, and Closed. For each one, click on Apply afterward.
  2. 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

  3. 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:

Figure 2.15 – BPF in action

Figure 2.15 – BPF in action

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:

Figure 2.16 – Ticket processing completed

Figure 2.16 – Ticket processing completed