Power Automate Desktop: How to Use Work Queues - Complete Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
where Q actions are now here in palogame desktop and they are great workqs are very efficient since they let us break multiple transactions into single tasks that our robot can do we are typically using a dispatcher and perform model and this simply just means that we break our flow into two we have our dispatcher flow the dispatcher flow will add the items to a queue as single items and then our performer model takes over and process these items one by one that's all there is to it it's very beneficial since it let us do load balancing and efficient scalability now multiple robots can perform these tasks that can just take one item from the queue then then the other robot can take another item from the Queue at the same time that is very efficient instead of just reading from an Excel sheet for example you can also do efficient error handling since now our errors will get tracked and locked and we can easily retry these arrows finally again we have a great logging ability I will show you that so stay tuned and that means that we meet all the Regulatory Compliance standards let's get started we'll first look at how we can create a queue and then we will create a dispatch and perform a model everything will work today you can build it yourself so please open up your own power automate desktop and a browser we'll start by going to a browser here I've logged into power automate.com that is the power to make Cloud you should do that too go down to Monitor and here we will find work queues that will be empty for you if you haven't worked with it to create a new queue we go up here and click new and over to the right you can see that we can give our queue a name today we will create a very simple process that will divide one number with another that is toy prices means that it's a simple process but it's a process that shows you how all these things work we can easily Implement much more advanced flows once we have understood the work queue actions so let's give it a name I will call this one divide we can give it a description and here we can say divide one number with another you can also give it a default time to live that is the queue items we will not do that I'll just click create we now have an empty queue so now I want to add items to it and what we'll do here is to go up to new and we can give it a name a name is optional but it's great because it lets us easily identify that particular queue item once we have maybe a thousand Q items so let's give it an identifier that corresponds to Something in the value and here we I just created a identifier called a thousand and one and let's give it a value and the value if you only have one value your robot should use that could be a salary or a personal identifier then you can just type it in here if you have multiple values then we need to separate it in some way so our robot can understand them you can do this by comma separated or creating a Json I recommend understanding the Json format it's really simple it's just j s o n Json that's just a way to write text so it can easily be interpreted by for example power to make cloud or power automate desktop it starts with the curly bracket then you click enter will have a new line here we have our data I'll wait two seconds with that click enter once more and end it with another curly bracket so everything inside this curly bracket that is our data I'll just have three values but you can add as many values as you have for example if you have an employee you want maybe the employee id address name Town postal code everything you want you can have it in here what we do is to have a double quotation marks and here we'll have an ID these are just made up but it could come from for example a database I'll show you how to automatically create these queue items because in real process they will come from somewhere we will get back to that so please stick so we'll have an ID and that is a thousand and one and that was also why I gave it this name so usually I want to have something that tells something about this value as the name then we will have a comma that means that we can go to the next value again a curly bracket I'll say number a double quotation mark colon and then this space is optional you don't have to have it and but it makes it a little bit easier to read then we will have a random number between 1 and a thousand let's go with 712 have another comment and now we will have number B like this and let's have two three four and have another double quotation mark so these are key value pairs that means that the key is the ID and the value is the Thousand and One and similarly the key is number a and the value is 712. we don't have a comma in the last time since we have no more values but we're going to create three items so what you want to do here is to Mark everything and click control C for copying it let's click create here you can see that if I click see all we now have a yq item in Z is cubed and we can also see the time here the value is over here and here we have a name that was the optional one it's much more easier to identify what's actually going on in this queue item let's create two more so I click new we will call this a thousand and two and then in the value press Ctrl V let me drag this a little bit down and we just need to change it slightly here so we will have some other numbers and another ID like this so that is our second Q item I'll click create now we have two let's have three so we have something to work with and again I will get back to how we will automatically create this queue these queue items and that was the dispatcher flow that will be in the end because that makes most sense we need to understand every part of this so in the value I'll press Ctrl V I will drag this a little bit down and here I'll say a thousand and three let's give it another number like this and we'll have a number B so now we have three transactions to work with I'll click create here and those ones are in our queue and easily go back here that is the overview but I recommend to click this see all when you iron the work a queue because that will easily let us get into the machine room now we can go back to Power automate desktop so let me open up power to my desktop let me create a new flow and here we can call this divide performer now we are creating the flow that will handle these transactions again that was the second part because the dispatcher came first we haven't created that one yet we added them manually and again we'll get back to those let me click create here a few seconds will win bye and again if you want to have the full example with a working example with web entry then I also created a best practice video up here in the right corner I recommend you go check that but please check this video first now we need an action and to process this work queue item you will search search for process work queue items and let me just make this a little bit bigger you'll find it here you can also let me do this and also scroll down to work using here we have our tree work you actions so we need to process where queue items I'll go in here the process work queue items that needs a queue so I'll just click the drop down here and here I'll find my three cues you might only have one that's fine we call it divide we created that in power automate cloud then we also have a variables produced that is called work queue item and let me explain what's going on here so if I click save here you can see that we have some sort of a loop here because we have a block called process where queue items and we have an end this means that this robot desktop robot will take these Q items one by one over and over until we have no more left let's since we are having that value in the Json and we did that because now we can split these value and work with those values here in power automate desktop to do so you will need to find a convert Json to a custom object let's drag it in here the Json that we are working with that will be the work queue item and we will need to pick the value from here because there will be a lot of information in this work you item we need the value that is where our Json lies this also means that this work queue item is the same for each transaction so that will be named the reference name will be work queue item go over to this little X here click this arrow and then you need to scroll down to find the value go double click that so this is the expression this is the Json that we want out and the variables produced that is called jsonness custom object let us go in here and let's just call it work queue item as custom object it's a little bit it's a little long name but that should work fine I'll click save let's check that this actually can work so I'll set a breakpoint out here click with your mouse to the left of the tree that will make a red dot that just means that robot will stop once it's finished the first iteration here so if I click run here you will see that we are looking into queue and then we are stopping at the end in fact we are just paused so until I click run we will not process the next transaction if you go over to the right and here you can see the work queue item as custom object you can see our ID here try to double click this ID over here and there you go now we have it as a custom object the reason why we converted it to a custom object from the Json is that this is very easy to work with now if I want to work with number a I can just say go look in this variable name up here where Q item is custom object and then give me this key very easy let's try to do so and I'll just click close here and what we will do here is to click stop because we don't want to process more items that will just be the same we also want to process to say I want to update the status and that was let me get back to the queue I also want to now they are cute and if I click refresh here and then you can see we now have uh the name that was the 1001 that is processing and that makes sense since we started that in power to Mid desktop but we didn't really do anything to it what we want here is to set the status as present so each time these are processed I know we don't do anything to them yet then we want to set them as processed and we also want to give a processing note and did it went well or what happened so let's go do that I'll go back here the next action that we're going to look at from the work queues let me do this that will be the update where Q item so after we have converted it we can update it let's just say that everything went fine I know we still don't do anything but please stick we will process them so here I'll just have a processed and then the processing result let's just call it success we will add more detailed message later so I'll click save so now we are also updating him so we take them one by one and then we're updating them in here still we have the breakpoint so we only process one and see how this works and then we will create a larger queue so later and then if I click run here now if I go to my queue my robot is still paused I go here and if I refresh it here you can see that now the next item that got processed and the processing node says success so far so good I think we also should process this data so if I go back to my desktop and then I'll click stop let's do a simple one and this could be a much more advanced process but again we keep it simple so we understand these actions let's go up to actions and then you'll finally convert text to number we will convert each one of the text numbers from the Json to a number so we can do a division with it so you will find a convert texter number and drag it in after the convert Json to custom object so what text do I want to convert well go over here to the X pick the work queue item as custom object like this go in here have a hard bracket a single quotation mark and here you will say number a like this and the variables produced let's call this number a so it's easy to work with now we have our first number as a number number a and we need a similar one for B we are very lazy as automation developers so simply just Ctrl C Ctrl V we now have two then we just need to go into the second one have a b instead of an A in both places so now we're converting them let's also um set a variable where we can do the conversion so here I will say set variable and now I will have this as child and then I can just divide number a with number B and again I can see up here let me just that I need an R something when you live code this you need to make sure that everything is fine but I also want to show you how this looks like in real time so you also get my smaller mistakes I hope you're fine with that because I think you can also learn a lot from them and basically I make a lot of mistakes so when you develop these things don't worry that you will see this syntax errors here and there it will um be natural and just you just need to know how to fix them so here I click save so now we're dividing this into a result let's update this update where Q item so we will have the success and let's also include their assault like this so now we're including the result in the processing node I can click save let's process the last work queue item and inspect our queue here so if I refresh you can see that we have now processed we have a success and then we have the result here we said in the beginning or I said in the beginning that this work you concept is great for handling errors and do logging let's see an example of that so let's look at this a thousand and one so let's set it back to cute I'll click these three dots change Q item status first I need to get the process status and apply that and then I can get it back to cute I click these three dots again change Q item status and click queued that's it I'll also need to produce an error and what could that be well we're not allowed to divide by zero that says math so let's click the three dots click edit and let me do this and that will be number B since that is the number that we are dividing with so let's give it the number zero this will produce an error I'll click save if we want to do the other two now again we can Mark those and unmark this and then we can click these three dots change Q item status and have an SQL to change a q item status they need to have the same status when you change them to something so here I'll just do this now we have three items in our queue let's build in the error handling in our flow and we will see that this concept also work so I'll click stop we need to do a check to check if number B is zero so after this convert Json to a custom object go find an if and drag it in here the first operand that will be work Q item as custom object and then we want to look up number B so a hard bracket single quotation mark number B like this so here I'm just saying is this number b equal to zero well then I know that something is wrong we could do this Arrow check in a lot of ways we can also have the arrow check down here but now we're just checking it up here so let's introduce a status variable that we can use for the Locking so I'll have a set variable and I'll drag this one in because if this is true then I don't want to process that particular item and I will say let's call this status and I will say that this should be a business exception that means that we have an error in our data if you want to know more about handling errors I created a very long video the description is in below here it's called best practices in power automate desktop for now this is sufficient I'll click save here so if this is not true that means that number B is not zero well then we can do these things here so let's have an else that means that we if this is true we perform this and else we do something else that means that this is the true Branch up here and this is the full branch false Brands down here so I take these three guys here and I drag them up here I also want to update my status variable to a success and have the result in that so here I'll find a another set variable and I'll have the status here and that one will be a success and here I'll have the result variable like this and I clicked save so now we know we can either have a business exception number B is zero or we can have a success but we could have more business exceptions say we do other checks on our data we can even have system exceptions so after this if here that means that when the transaction has processed either it will just have a status as a business exception or it will get processed then we need to have some sort of we need to ask what happened here and then we can update the word queue item accordingly because we want a customized message we either want a processed or we want a business exception as status to do this we can use an if but because we might want to have a different error messages here now we only have one business exception but since we can have a system exceptions system exception or general exception then we will use the switch a switch is basically the same as nif it's just a little bit more advanced we can ask we can look at one value and then we can have multiple branches so we don't need to make a nested if the value to check well we'll just look in our status because in this status we have the information is this a success or business exception I'll click save so what is going on in here well now we do cases and that means that we look at each one of the outcomes that we can potentially have up here from the status and then we can process them our first case that is if let me do this starts with here if this starts with a success then we know everything went well and we can do something here so what are we going to do well we're going to have this success update working item success let's double click it and here we can just delete this and have the status since the status already have this then it's redundant to write it once more and we will have the status as processed that one is fine we also need to handle the business exceptions so we'll make another case here I can make it in front that doesn't matter so here we will say if this starts with business exception and this then need to correspond to this you need to spell it right and this has the advantage that this will catch every business exception that we will have up in our processing flow that's handy because we might want to do more data checks say that maybe number a or number B could be empty then we can also make a data check there and have a customized message but for now we will just have this one here so we need another update where Q item I can either search for it or I can find it here drag it in here and that is because we need to change the status and this unfortunately doesn't allow us to do Dynamic content you can see and only pick from this drop down so I'll need to pick the business exception and that is why we need to create two of them then the processing result again let's just do the status we have all the information in here I can click save so now our flow is really our performance yes it's simple we only do three tasks in here and of course we also have some error handling but that's it let's remove the breakpoint by just clicking here and again we have our queue let me go back to that and we can refresh it you can see that each of our Q items those ones are cute let's run it that will process the three queue items and we will have done exceptional log and error handling here in our little toy flow that's it so I go here and then I can refresh it and here you can see that we have the two successes those ones looks fine and we also have a business exception now and here you can see we even have the processing node saying what went wrong here so now we have built um the performer model we still need a dispatcher that is because we are adding these manually I want to have them added automatically so we need some data and I have some data here in my Google Drive folder that is just an Excel sheet to download those you will need to click file download and take the Microsoft Excel that will start a download up here I can open up the folder and here you have it in downloads let me minimize everything and I'll just drag it out here on my desktop open it to inspector data here I have two sheets I can enable editing if I want here I have two sheets the first sheet which is just the numbers and then we have our actual data and the data here and again that looks very similar that is transactions we have an ID number A and B and you can also see we have three business exceptions where the number B is zero and these guys here that could be employee data that could be customer data that we want to process One By One The Usual standard is that we just read our Excel sheet in our flow and then we start our robot to work but what happened if our robot crashes then it's hard to start at the correct place with work use we are allowed to process them as single transactions our flow will record if something or work you will record if something goes wrong and we can easily start and stop from the correct Place let's try that so the sheet is called numbers and this one is placed on my desktop place it wherever you want shift right click here and then you'll choose copy as path and that is because we want to get the path to this Excel sheet we have our performer now we need a dispatcher so I create a new flow and here I'll say divide dispension and again this comes before the performer this once is the one that reads the data that our robot needs to process and upload them to the queue go here so we want to create a variable for our Excel path always nice to use Dynamic values the variable name that will be Excel path go down here Ctrl V there you go your path to your Excel book like this then I can click save now you go find a launch Excel here and drag it in I want to launch the following document here and I have that as a variable so simply just click the X double click the Excel path untick the make instance visible and click save before I read it I want to make sure that we're reading from the numbers sheet since we have multiple sheets in that book we have two so I'll find a set active Excel worksheet and drag it down here I'll activate the worksheet with the name numbers and we are in the Excel instance that we created up here then I can click save then I want to read from Excel worksheet so I'll say read from Excel worksheet I want to read all available values from the worksheet so go pick that in the advanced say first line of range contains column names and that is because we have headers in our Excel sheet and of course this Excel sheet you can also find that in the description below so here I'll say Excel data numbers and then I'll click save now we can iterate through this Excel sheet and add these rows one by one to our queue so find a fridge here what value do we want to iterate that will be this data table called Excel data numbers like this and we have a reference called q and item that will be a reference to the current row that we are iterating F so that one will change once we are processing this now we can use the add where Q items again from the work use either search for it or simply just find it here in the work use drag it in here we need some information the work queue well that is divide we worked with that we know that and then we want a name and that one was our ID we also had this in our Excel sheet so here you go find the tuned item hard bracket single quotation mark since we're now on the data table and a hard bracket and so this is the current Item ID since we're going to use this reference a couple of times go Margaret and Ctrl C now we need to do the Json once more since we need to take the current ID the ID the number a and b mix them to a Json that can be used in our queue and that our robot the performer can process so again we will have the curly brackets let's do two enter clicks and a curly bracket and now we can have them so we'll just do as before ID and then surrounded by double quotation marks a colon like this we'll need a quotation mark then you'll do the control V and a con quotation mark double to end it then you'll have a comma now we have a new line double quotation mark number a double quotation mark colon let's just do Ctrl V because then it's very easy again we're lazy to go in here and change this to number a then we will have a comma and since we're now doing number B let's always copy paste as much as possible as an RPA developer you will make fewer mistakes and it's faster so I'll just do Ctrl V here and if we wrote it correctly this will now be number B so now we are taking this Json and adding in to as a separate Q item we can also set the priority Express and processing nodes we don't want to do that and the variables produced it called where Q item now I can just click save here we are adding these a work quite we're adding these items to the wire queue what I want to do here is also close the Excel power to my desktop is a little bit sensitive with Excel so always remember to close it close it we are not doing anything in the document of course you could add a little status if you want that that these ones haven't been added to the queue we are not doing that in this story example this dispatch is now ready to add Q items but let me go to my queue again let me delete these three guys here I can click up here click delete just so we have an mgq with fresh items coming in so let's go here let's first have our dispatcher let me click run we are launching Excel and then we're adding these ones as we're queue items okay you can see it takes like one second for each each transaction you can reduce the Run Delay from 0.1 millisecond to 0. [Music] um two to one milliseconds are here and that is the delay between the actions doesn't matter here the distal layer is here so we can easily see what's going on when we edit it will be gone if we run it from the overview or from power to make cloud so now if I go to my queue I refresh it you will see that we now have 20 Q items then we can start processing them and of course we want to do it with the error handling that we saw worked before so we go to our performer remember to have moved this breakpoint from the end let's start it and hear what I said was that we can set the Run delay to one and then I can run it runs a little bit faster doesn't really matter hold up so now we're processing processing them let's say that this was a long process go in here to my queue and I can inspect them while the robot works here you can see that we have two business exceptions we have some processed and this one makes it easy to inspect what the robot is doing while it's actually run that could be a little bit difficult and now we have run you can see here that we have all the successes and we have three business exceptions and that is because the number B is zero I can go into that specific one here you can see now the b0 that was correct and then I can contact the department that delivered the data and said something is wrong with the data now you should learn about work queues in power to make Cloud as well it's done a little bit different the guide is right up here do we want to learn more advanced power automate desktop then you should join my I love automation Discord Community we are more than 8 000 RPA developers helping each other with power ultimate networking with our careers and motivating each other your guide and invitation is right up here thank you for watching and please like this video if you find it great
Info
Channel: Anders Jensen
Views: 4,295
Rating: undefined out of 5
Keywords: Power Automate Desktop, Work Queues, Microsoft Power Automate, Power Automate Tutorial, Power Automate Desktop Tutorial, Work Queue Actions, Work Queue Dispatcher, Work Queue Performer, Add Work Queue Item, Process Work Queue Items, Update Work Queue Item, Advanced Power Automate Desktop Flows, RPA, Robotic Process Automation, Microsoft RPA, Process Automation, Workflow Automation, Power Automate Desktop Workflows, Microsoft Automation
Id: paYO_AsU4ek
Channel Id: undefined
Length: 35min 22sec (2122 seconds)
Published: Tue Jul 18 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.