Power Automate- The Power of a Workqueue
Tags: powerautomate, powerplatform, workqueue, rpa
Published: 2022-12-08 09:33:09

A workqueue is maybe something you haven't heard of, but it's pretty easy to guess. Its a list/queue of jobs to be done. In Power Automate there is no workqueue, but in other RPA tools there are. In Blue Prism the workqueue is the central hub of all automations, and there's a reason for that.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mntdnn39sz2kzbjn8n7e.jpg)

Workqueues can be incredibly powerful, and have some key features, for Power Automate here are a few:

1. Track Success & Exceptions
2. Multi Conditions
3. Wait/Bulk
4. Human in the loop
5. Distribute to different flows to keep under API limits
6. Segregate Connections

So let's dive in and show why, and how easy it is to create a workqueue.

---

## 1. Track Success & Exceptions
There are multiple ways of reporting exceptions, but workqueues to it best. The main reason is that they also track successful runs (Power Automate run logs are terrible, max 100 or 30 days and no easy way to extract it). Having a log of all successful and failed runs/actions, is great for debugging, load planning and generating Return on Investment reports.

## 2. Multi-Conditions
You may think that Power Automate trigger conditions cover everything, but they don't quite. The example I use all the time is block runs. So lets say you have a process that needs 3 emails with certain information before it can run. Its not possible to set that in a trigger condition, but a workqueue allows you to create a job, and have conditions on that job to run only if all emails have been tagged as arrived in the job.

## 3. Wait/Bulk
Scheduling runs normally covers waits, but what if you have a certain threshold instead, lets say when there has been a 100 responses in a form. In these scenarios a schedule wont work. But having a workqueue you can set a flow to only run when there are 100 jobs in the queue.

## 4. Human In the Loop
Approvals and Emails with options are a great human in the loop tool, but sometimes they can become almost spam. Imagine having a hundred items that need approving, sending them one at a time would definitely become annoying. But with a workqueue you can block approvals, so you could set a schedule to send current open approvals to the approver. They then work directly in the workqueue, approving, rejecting or updating them in bulk.

## 5. Distribute to different flows to keep under API limits
This is obviously a fringe case, but let's imagine you have a complex or a very high volume flow. The 40,000 Power Platform api call limit can be hit. Microsoft offers 2 solutions, an api add on, or a Flow only license (250,000 api calls), both not cheap. But there is another way, a workqueue. By passing jobs into a queue different service accounts can pick them up and run the flow. An example would be 2 accounts, one picking up even jobs, the other odd.

## 6. Segregate Connections
Again another fringe case, but in some scenarios security may not like one account having too much access to too many systems. With a workqueue a process can be split, with one account with one set of access doing part, and an another with different access doing another part.

---

So here's an example of how a workqueue can be powerful.

- One flow picks up all emails and saves them as jobs in a workqueue.

- Due to volume and complexity the work is then split to 2 service accounts, one doing even jobs, one doing odd. Once complete they update the jobs category and status.

- Any jobs that can't be processed due to not meeting standard responses are tagged in the workqueue as 'uncategorised'.

- A flow checks every hour if there are 100 jobs categorised, if they are it then packages them up and passess them to a Power Automate Desktop worker to process on an on prem system. It also checks for 10 jobs tagged as 'uncategorised' and sends a link to the workqueue for someone to categorised them. Here they can be updated/categorised so that the Desktop flow can process them.

- At the end a Power BI dashboard is linked to the workqueue as a data source, with Successful vs Exception rates, hours and payroll saved displayed. 

As you can see, it would be almost impossible to complete the process without a workqueue.

---

So how do you have a workqueue in Power Automate, Im sure you have already guessed, SharePoint Lists. They are ideal for workqueues, as they don't need relationships, are flexible to cover any data that needs to be added (including files), they link to Power BI easily, and best of all they can trigger flow runs.

The above example would look something like this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tzuxegzq02ryhwyhesa.png)

---

And I have barely scratched the surface, there are lots more great use cases for workqueues. They add so much flexibility when designing solutions, and are a great tool to have in your arsenal.

---

**Further Reading**

- [bpdocs.blueprism.com](https://bpdocs.blueprism.com/bp-cloud/iada-orchestration/iada-orc-orchestration-st.htm?TocPath=Standalone|Standalone%20version%20user%20guides|IADA%20Orchestration|_____2)
- [https://learn.microsoft.com/en-us/power-apps/developer/data-platform/queue-entities](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/queue-entities
)