Exercise - Create a cloud flow that calls a Power Automate desktop flow

Completed

By the end of this exercise, you will be able to create a Power Automate cloud flow which runs a Power Automate desktop flow. The flow is designed to approve or deny an employee's request for time off.

The flow works as follows:

  1. Power Automate requests 3 inputs from the user. A first name, a last name, and the amount of days off an employee is requesting
  2. Power Automate passes all three inputs to Power Automate for desktop as input variables.
  3. The Power Automate desktop flow writes the values of these variables to a new row in an open Excel sheet
  4. A message box prompts the user to approve or deny the time off
  5. Power Automate for desktop writes the result of the approval request to the Excel sheet and passes it back to Power Automate as an output variable
  6. Power Automate uses the result of the approval request as a variable and sends an e-mail containing the value of the variable

Exercise

  1. Create an Excel file, save the file with the name Time Off.xlsx and do not close Excel. Enter the headers in the first row in the following order: First Name, Last Name, Days Requested, Approved

    Screenshot of Excel spreadsheet with headers added.

  2. In Power Automate for desktop, select New Flow and specify a flow name.

    Screenshot of the Build a flow dialog with the flow name set to Update time off spreadsheet.

  3. Add an input variable. Repeat this three times, specifying the fields as follows:

    Variable Name External Name Description
    FirstName FirstName The first name of the employee.
    LastName LastName The last name of the employee.
    TimeOff TimeOff The amount of time requested in days.
  4. Add an output variable with the following properties:

    • Variable name: Approval
    • External name: Approval
    • Description: "Yes" - Approved, "No" - Denied
  5. Add the Attach to running Excel action. Specify the Document name, entering Time Off.xlsx.

    Screenshot of the Attach to running Excel action dialog.

  6. Add the Get first free column/row from Excel worksheet action.

  7. Add a Write to Excel worksheet action. Repeat this three times, specifying the fields as in the following table:

    Value to write Column Row
    %FirstName% A %FirstFreeRowOnColumn%
    %LastName% B %FirstFreeRowOnColumn%
    %TimeOff% C %FirstFreeRowOnColumn%
  8. Add a Display message action, and fill in the parameters as follows:

    • Message box title: Approval Required
    • Message to display: %FirstName% %LastName% has requested %TimeOff% days. Approve leave?
    • Message box icon: Question
    • Message box buttons: Yes - No

    Screenshot of the Display message action dialog.

  9. Add a Set variable action, and set Approval to %ButtonPressed%.

    Screenshot of the Set variable action dialog.

  10. Add a Write to Excel worksheet action, and select the following parameters:

    • Value to write: %ButtonPressed%
    • Column: D
    • Row: %FirstFreeRowOnColumn%

    Screenshot of the Write to Excel worksheet action dialog.

  11. The completed desktop flow should look like the following figure:

Screenshot of the completed desktop flow.

  1. Go to flow.microsoft.com

  2. Select Create and Instant cloud flow.

  3. Add a flow name, and select Manually trigger a flow

  4. Select the Manually trigger a flow action, then select Add an input and Text to add three text inputs as follows:

    Title Description
    First Name Enter the employee's first name
    Last Name Enter the employee's last name
    Time Off Enter the time off requested in days

    Screenshot of the Manually trigger a flow dialog with the parameters set.

  5. Add a new action and search for the Run a flow built with Power Automate for desktop action.

    Screenshot of the Choose an action search results.

  6. Select the Update time off spreadsheet flow made previously and set Run Mode to Attended. Set the three variables to their corresponding values from the text inputs of the first action, using dynamic content.

    Screenshot of the Run a flow built with Power Automate for desktop action.

  7. Add a Send an e-mail (V2) action. For the purpose of the exercise, send an e-mail to your address. Set Subject to Days Off Request and use dynamic content to set the body as in the figure below:

    Screenshot of the Send an email v2 action dialog.

Note

The Approval variable originates from the Run a flow built with Power Automate for desktop action.

Save and test the flow. Enter the inputs as requested.

When the flow runs, notice that the spreadsheet is updated and a dialog box prompts the user to approve or deny the requested time off. The e-mail is also sent to the provided address containing the result of the request for approval.