Exercise - Create conditional logic

Completed

In Power Automate, you can add conditions to take different actions depending on a certain result, in this case, to indicate whether the request was approved or rejected.

Note

To complete the exercises, you'll need to use a few files. Download the App in a Day files for use in this module. The file folders that are in this download include:

  • Completed modules with instructions - Package files to import the completed exercise steps.
  • Machine-Order-Data.xlsx - File used in the exercises.

Section 1: Add conditional logic to the flow

In this task, you add conditional logic to the flow by following these steps. If you closed your flow from earlier, you can find your flow in your solution and choose to edit.

  1. Select + under the Start and wait for an approval action. Then select Add an action.

    Screenshot with a highlight around the plus icon and Add an action icon.

  2. Search for and then select Condition.

    Screenshot showing the Condition action selected.

  3. Select the Choose a value box and select Outcome from the Dynamic content pane. Remember to select the lighting bolt icon to access the dynamic content.

    Screenshot with a box around the Outcome option in the Dynamic content pane.

  4. Select is equal to for the condition and then type Approve for Value.

    Screenshot with the condition set to "is equal to" and Approve typed into the value field.

  5. Save the flow.

Section 2: Set up actions to perform

Now, you set up what actions to perform if the response is approved or not: True branch vs. False branch.

You add two actions:

  • Update the record in the Machine Order table.

  • Send an email to the employee who requested the machine.

Follow the steps to add the actions.

  1. In the left True box, select the + icon and select Add an action.

    Screenshot with a box around the Add an action button.

  2. Search for Update a row and select Update a row (Microsoft Dataverse).

    Screenshot of the words Update a row entered in the search field.

  3. Select Machine Orders from the Table name dropdown menu.

  4. Select the Row ID and then select Machine Order from the Dynamic content pane.

    Screenshot of the Machine Order dynamic content entered in the Row ID field.

    Every time you create a table in Dataverse, a column is automatically created with the same name of the Display Name of the table. This column serves as the unique lookup ID for the record (or row) that was created.

  5. Select Show all next to Advanced parameters.

  6. Select Approve from the Approval Status dropdown menu.

    Screenshot with a box around the Approval Status value field.

  7. Select the Approved Date field and then select the fx icon to write an expression.

    Screenshot with a box around the Approved Date field with the a box around the fx icon.

  8. Type utcNow() in the window above the Function tab and then select Add.

    Screenshot with a box around the Approved Date field with the function typed into the box on the right and showing the Add button.

    Screenshot with a box around the Approved date field.

  9. Save the flow.

Section 3: Add another action

Your next task is to add the send email action to the True branch.

  1. From within the True branch, select the + icon and then select Add an action.

    Screenshot  of the Add an action button in the True branch of condition.

  2. Search for send an email and select Send an email (V2) - Office 365 Outlook.

    Screenshot showing the Send an email (V2) Office 365 Outlook option under Add an action.

  3. Select Sign in if prompted.

    Screenshot of the Sign in pane.

  4. Select Switch to Advanced mode and then select the To entry.

    Screenshot showing the Advanced mode check-box.

  5. Select Requested By from the Dynamic content window from under the When a row is added, modified, or deleted action for the To field.

    Screenshot showing the Requested By dynamic content being added to the To field.

  6. In the Subject field, enter Your machine order has been approved!

  7. In the Body field, enter Your machine has been approved and select Machine Name from the Dynamic content pane from under When a row is added, modified or deleted.

    Screenshot showing the Machine name dynamic content added.

  8. In the Body field, hit return to move to the next line. Enter Estimated ship date: and select Estimated Ship Date under Update row from the Dynamic content pane.

    Note

    If estimated ship date is selected from When a row is added, modified, or deleted NO ship date returns in the email as this value isn't populated until the approval status column contains data. This was the business rule set up earlier in a previous exercise.

    Screenshot of the Body field filled in and the Machine Name and Estimated Ship Date dynamic content added.

  9. In the Body field, hit return to move to the next line. Select Response summary from the Dynamic content pane from under Start and wait for an approval.

    Screenshot of the Body field filled in and the Response Summary dynamic content added.

    Note

    If you don't have a Microsoft Office 365 mailbox set up, you can use another connector to send the email, such as Outlook.com, Gmail, or SendGrid.

  10. Select Save. You can now close out of this flow designer browser tab.