Exercise - Create a work queue

Completed

In previous labs, you created an end to end solution to enter an invoice to a legacy application. That solution, which runs a desktop flow from a cloud flow, lets you automatically enter relevant data into the legacy application without having any manual process take place. When triggered, this flow is placed in a queue with all other desktop flows that are set to run and only run when its turn in the queue is up in the order. But, a question remains - what if that order needs to be modified so a specific flow run takes higher priority than others?

Work queues in Power Automate play a crucial role in improving the efficiency, scalability, and resiliency of automations and help prioritize work, with the highest-priority items being completed first, regardless of whether they're processed by digital workers, human workers, or through integrations.

Just as manufacturing assembly lines are designed to decouple different complex stages of production, work queues can help decouple different areas of a process allowing each part to operate independently and exchange prioritized inputs and outputs asynchronously.

Task: Create a new work queue

  1. Go to Power Automate and sign in with your credentials.

  2. Within the navigation menu to the left of the screen, select More with the ellipses next to it. Then, select Work queues.

    Screenshot shows the more and work queue buttons from the navigation pane.

  3. This takes the user to the work queues section. Select the + New work queue button or select the +New button at the top of the screen to create a new work queue.

    Screenshot shows the +New button for the Work Queues page.

  4. In the New work queue panel, enter the following information:

    • Work queue name: Invoices
  5. Then, select Create.

    Screenshot shows the entry of data within the pane for the new work queue.

    Note

    If you set an expiration time for a work queue, any item added will expire after the time has elapsed. So if you set expiration time to 30 minutes, an item added at 2:00 PM will expire at 2:30 PM.

    Screenshot of empty work queue.

Task: Create the Work Queue Item Load workflow

  1. From within the Invoice Processing Solution created in a previous lab, select + New from the toolbar at the top. Then, select Automation and Desktop Flow to create a new desktop flow.

    Screenshot shows how to select new desktop flow from within the Solution.

  2. Name the flow Work Queue Item Load, then select Launch app. You're taken to a new tab in your browser and might need to sign into Power Automate Desktop if prompted.

    Screenshot shows the dialog box to name a new desktop flow.

  3. Once in the Power Automate Desktop designer, navigate to the Excel section and select the Launch Excel action to add as the first step of the workflow.

    Screenshot shows the Launch Excel action in Power Automate Desktop.

  4. In the Launch Excel action, select the Launch Excel parameter dropdown menu and change it to and open the following document.

    Screenshot shows the Launch Excel parameter.

  5. Change the Document path and select the file named Work Queue Vendor Invoice Items from the folder Lab #13 Excel file for Work Queues in the course materials.

    Screenshot shows the file to be uploaded in the Launch Excel action.

  6. Select the toggles as shown here to turn off Make instance visible and turn on Open as ReadOnly, then select Save.

    Screenshot shows the details of the Launch Excel action.

  7. From within the Excel actions area, select the Read from Excel worksheet action and add as the next step.

    Screenshot shows the Read from Excel worksheet action in Power Automate Desktop.

  8. Select the dropdown menu in the Read from Excel worksheet action for Retrieve and select All available values from worksheet. Then, select Advanced and toggle First line of range contains column names to on. Lastly, select the variable produced and add Invoices to the name of the variable to display as ExcelDataInvoices.

    Screenshot shows the details of the Read from Excel worksheet action.

    Note

    It is a best practice to rename variables as necessary to make it easier to understand the purpose of the variable and how it is to be referenced.

  9. Navigate to the Loops actions section and select the For Each loop action.

    Screenshot shows the For Each action.

  10. Select the variable icon to choose the ExcelDataInvoices variable to iterate over, then edit the name of the variable that the data is stored into to be CurrentInvoice and select Save.

    Screenshot shows the variable to select in the For Each loop.

    Screenshot shows the final details of the For Each loop action.

  11. Navigate to the Work Queues section in the Action pane and select the Add work queue item action. Ensure to drag the action inside of the For Each loop.

    Screenshot shows the Add work queue item action.

  12. Within the dialog box, add the following information, then select Save.

    • Work Queue: Invoices

    • Status: Queued

    • Priority: Normal

    • Name: %CurrentInvoice['InvoiceItemID']%

    • Input:

        {
         "AccountName": "%CurrentInvoice['AccountName']%",
         "ContactEmail": "%CurrentInvoice['ContactEmail']%",
         "Amount": "%CurrentInvoice['Amount']%"
        }
      

    Screenshot shows the Add work queue item action with completed details.

    Note

    The square brackets [ ] with single quote ' ' designate a column to be referenced.

    Note

    The input in this case is a JSON object that is storing data in name/value pairs.

  13. Navigate to the Excel section in the Actions pane and add the Close Excel action as the last step in the flow, outside of the For Each loop. You don't need to make any modifications to this action.

    Screenshot shows the Close Excel action.

    Screenshot of the Close Excel action dialog box.

  14. Select the Save button and then select the Run button to run the workflow.

  15. Close the Power Automate Desktop designer window.

  16. Navigate to the Power Automate cloud flow portal at make.powerautomate.com and select More and choose Work Queues from the menu. Notice the 30 queued items for the Invoice work queue.

    Screenshot shows the 30 queued items in the Invoice work queue.

  17. Select the Invoice work queue, and notice the list of items, then choose See all to view the full list of items that are queued by the recently run workflow.

    Screenshot shows how to select See all from the work queue item list.

Task: Create the Work Queue Item Processor workflow

  1. Return back to Power Automate Desktop.

  2. Select the ellipses for the Enter an Invoice flow created in an earlier lab and select Create a copy from the dropdown list.

    Screenshot shows how to create a copy of a desktop flow.

  3. Rename the new flow to: Work Queue Item Processor

    Screenshot shows the how to rename a copied desktop flow.

  4. Select the new flow Work Queue Item Processor and select the pencil icon to edit it.

    Screenshot shows how to edit the Work Queue Item Processor flow.

  5. Navigate to the Work Queues section in the Action pane and select the Process work queue items action. Insert this action after the Run Application step already included in the flow.

    Note

    This should be the new action 2 in the workflow.

    Screenshot shows the Process work queue items action.

  6. Select the Invoices work queue from the dropdown.

    Screenshot shows the Process work queue items dialog box.

  7. In the Actions pane, search for Json and select the Convert JSON to custom object action, making sure to add inside of the newly created Process work queue item loop.

    Screenshot shows the Convert JSON to custom object action.

  8. Select the variable icon {x} to choose the JSON value to convert. From the dropdown list, scroll down and select the expand arrow for WorkQueueItem, then select the .Value option. Click Select to add this to the parameter area. Once added, select Save.

    Screenshot shows how to access the WorkQueueItem.Value.

    Screenshot shows the dialog box for the Convert JSON to custom obeject action.

  9. Select the Save button at the top of the window.

  10. Select the number 4 in the list of actions to add a Breakpoint to the flow. This Breakpoint stops the flow at the action it's added to, and allows users to view the details of the flow at that stage.

    Screenshot shows the added Breakpoint.

  11. Select the Save and Run buttons at the top of the window.

  12. Double-click on the JsonAsCustomObject variable from the Flow variables area in the Variables pane to view the output details from the flow that is running.

    Screenshot shows the JSON As Custom Object variable selection.

    Notice the data that was parsed from the JSON that can now be used as Name/ Value pairs. Select Close to close out of the window.

    Screenshot shows the details from the JSON As Custom Object variable.

  13. Select the Stop button at the top of the designer window.

    Screenshot shows the Stop button in Power Automate Desktop.

  14. Within the Work Queues section in the Action pane, select the Update work queue item action and drag into the list of actions after the Convert JSON to custom object step inside the for loop.

    Screenshot shows the Update Work Queue Item action.

  15. Add the Processing result: Success into the dialog box for Update work queue item and select Save.

    Screenshot shows details for Update Work Queue Item action.

  16. Select the Save and Run buttons at the top of the window.

  17. Return to the Power Automate web browser at the Invoice Work Queue previously visited. Refresh the browser tab and select See all.

    Screenshot shows the work queue items list and the see all button highlighted.

  18. Scroll down to the bottom of the list and notice the item that processed during the previous desktop flow run.

    Screenshot shows the work queue item list and the successfully processed item.

  19. Return back to the desktop flow designer and select the Stop button at the top of the window.

  20. Holding down the Ctrl key on your keyboard, select all of the actions from the original Enter an Invoice desktop flow then, drag all of those steps into the Process work queue items loop, between the Convert JSON to custom object and Update work queue item actions.

    Screenshot shows the selection of actions and moving them en masse into the loop above.

  21. Edit the three steps that Populate text field in window and remove the previously used Input variable to replace the Text to fill in with a value from the parsed JSON stored in the JsonAsCustomObject variable.

    Screenshot shows how to edit the Populate text field in window action.

  22. Use the following to replace the Text to fill in for each action:

    • Account Textbox: %JsonAsCustomObject['AccountName']%
    • Contact Textbox: %JsonAsCustomObject['ContactEmail']%
    • Amount Textbox: %JsonAsCustomObject['Amount']%

    Screenshot shows the details to edit the populate text field in window action for account name.

    Screenshot shows the details to edit the populate text field in window action for contact email.

    Screenshot shows the details to edit the populate text field in window action for amount.

  23. If there's a Breakpoint on line 16, remove it. Select Save and Run one final time to see all of the work queue items processed by this flow.

    Screenshot showing to remove the breakpoint and save and run.

  24. Return to the Power Automate cloud portal and notice the completed work queue item runs in the Invoice work queue.

    Screenshot shows the completed work queue items list after the full workflow is successful.