Power Automate Desktop: Best Practices for Advanced Users

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Advanced power automate desktop today we will look at the best practices around exception handling building a configuration file shop flows data validation work queues and do real time logging I'm anas Jensen a Microsoft most valuable professional and let's start by building a sample flow and then we will add all the Advanced Techniques to that today we are building one flow and then we will apply all the best practices to that workflow go to Power automate desktop and then click new flow we will call the flow best practices demo and then we'll click create that will open up a blank workflow I prepared a web page it looked like this this mimics one of the things that we can see as an RPA developer probably what we see the most this is a system that we want data to go into so here we want the workflow to do a student ID first name a last name and then you want to click add student here you can see the student successfully got added and we can see the student down here in the table but we can also produce errors let's say that we have a student ID of an invalid format like this and try to add this you can see it will not get added and it produces a mirror message this is one of the things we want our workflow to handle but we also want to do logging configuration cues we want to do the whole package we need to build the perfect flow so stay tuned first we will download some Excel sample data go up here and click download that will take you to a Google sheet go into file say download and choose Microsoft Excel like this that will download it let me open up the folder here let me minimize everything and then we move it to our desktop like this I can also close this we will create a folder for our project so we have everything in one place keep in mind that we do it here on the desktop normally when we develop it's fine to use the desktop but we won't use the desktop to store the project files when we move them into production in that case we will move them to for example the network drive where several people have access to them here I'll say new folder I will say project I'll move my students into that and now this will be the working folder today let us open it it's also open the student xlsx I will drag it in here from my second screen and here you can see that we have four sheets the first sheet we will work on is the student stream here we have three students so what we want here is to fill in these three guys here or women into our system at first these are three successes we will not be getting any errors so that is the basic flow that we want to build when we have built that we will start adding best practices to the workflow one by one so here we want to go into the students tree and let me let me close this I also want to grab the project path here that is this folder so what you do here that is important click shift on your keyboard and then when you right click you will see your copy as path you will not see it if you don't click shift so you need to click shift hold it down and then right click choose copy as path then we can go back to our power automate desktop flow so here we have the blank flow let's use a region regions upgrade too clean up our flows it looks like this a drag in a region we will give it a name let's start by having the initially session it's always a hard to spell for me but this should do it I'll click save a region will be ignored at runtime the region itself but everything in will be performed so it's an excellent way of keeping track of your different groups of actions and I'll definitely recommend you to use it let's use a variable in here so I'll go up here and then I'll find a set variable I'll drag that in here we will give it a name and I will call it project path and then I will control V paste in the path to the project folder delete the quotation marks and regarding variable naming you can see here that the project path we use the Pascal naming convention that's the default that Microsoft uses here in power automate desktop and it's also the one that I will recommend you to use that means that we start everywhere variable with a capital letter and each new word in that variable name we will start with the capital letter two so here we have the project path p and p are capitalized asset let's click save here we also put in all the variables where we have data in that can change imagine that I moved this workflow to either a different folder when I finish developing it or I move it to a colleague's computer then it's easy to have the set variable in the beginning right here my colleague or myself just need to open this and change this path then everything will work so what we also need to do I'll also be sure to have an active Excel sheet variable so we can Define which Excel sheet we want to read from that's another best practice we will do that because otherwise power automate desktop will just open up the last used so first we will launch it I'll find a launch Excel and I'll drag that in here that will go into the initialization we'll read the data into a data table and then we will work with it later on here we want to opening up the following document what do we want to open well I've stored the project path in the project path variable so I simply just click this x here and choose the project path that's another important one I really want you to use these variable Pickers out here to the right instead of just writing in yourself in that way we make less mistakes then we want to say I want to open up the students book so that will be a backwardslash students and then Dot xlsx we will not make it visible and if I scroll down I can see that we produce a variable called Excel instance that's great I can click save now I want to set the active Excel worksheet but let's create a variable for that here in the beginning as well so we can easily change that in the action it goes like this here I'll find a set variable I'll drag it in as the second then I go up here I will call this one active Excel sheet and since we're going to start with the students tree we're going to give that as a value then I can click save now I can use the set active Excel worksheet down here right after the launch here I'm going into the Excel instance I want to activate the worksheet with the name students tree and that value is saved in a variable then that one will also be very easy to change once we will use different sheets so here I'll take the active Excel sheet and this is important to use the set active Excel worksheet otherwise your power to make desktop flow will just read the last Excel sheet opened or activated and click save now we can read from it so we specified the sheet that we want I'll find a read from Excel worksheet and then I'll drag it in here what do I want to use the value of a single cell no I want to use all available values from worksheet then I go into advanced our data got a headers column or headers row so I will have it this one ticked first line of range contains column names then the variables produced is called Excel data here we sometimes we often want to use a name that describes the data within imagine that we even have more sheets written in our flow then it will be very important we will not have that today but let's call it Excel data students like this then we can click save we also want to close this Excel book again otherwise power automate Canon will lock it for further use so I go up here and then I'll find a region and I'll drag in a region below this this will be the end region so we will call it end just find a close Excel so I go up here and then I'll find a close Excel and drag it into the end we will not choose to save this Excel book for now but we'll definitely do it later then we can click save now try to run your automation by clicking run here and again the regions themselves will get ignored at runtime it's just a way to systemize your workflow and one thing that we can do is you can even see we can do this then it's much cleaner to look at we have five actions here and one action here once you have run your workflow I can try to run it again I just did but if you didn't please pick run then it will run and what you need to see over here in the Excel data students in case you don't see this variables to the right just click this x here go down here double click the three rows four columns that will open up our data set it looks fine the Excel data students is what we're going to need to process our data so I can click close we also need to go to a web page and that was this web page we saw in the beginning so grab the URL up here Ctrl C go back to Power automate desktop we will open up the initialization drag in a another set variable that will store our UL let's drag it here I'll call this one URL and I'll control V paste in our URL so here sometimes when the name URL you will always see that written in with capital letters then we will differ from the Pascal notation and then simply just write URL with capital letters but should we follow the Pascal strictly it will look like this but again you will always see a UL in capital letters this will make it easier to read and understand what's going on then we'll click save now we also need to open up our browser so we can open it up here into the initialization it doesn't matter really where but I will find a launch new then I'll take a Microsoft Edge I recommend you to use Edge or Chrome those ones are the most stable I use a lot of Microsoft so Edge is natural for me feel free to use Chrome or even Firefox just never go with Internet Explorer that one is outdated and not secure so I'll drag in this launch new Microsoft Edge I can choose to have it I prefer to have the Excel Block in the same place so I will not place it in between it all either place it before or after I can do it before we need a URL we just created a URL for that a variable here that will be stored in here I'll choose to maximize the browser once it runs nothing important for the workflow itself but when we demo here it's nice to see it on the whole screen here we'll produce a variable called browser I can click save so now we're opening up our browser I've also read the data we can start to Trend do the transactions here in our workflow and one transaction is one student go up here find a another region and drag in the region between the end region from the initialization and before the region end start here this one here we can call transaction I think or process transaction so transactions that or process transactions doesn't really matter pick names that will make it easy for you to understand not not like region 1 Region 2 or Region 3 that will make it hard to come back to these names make sure that I can easily see what's going on when we come back so in this transaction we want a for each to iterate to our data so I'll find a fridge and drag it in here here I want to iterate through the Excel data students so I go up here pick the Excel data students and again this current item that is a reference for each one of the data rows that we can refer to pick a name that says something about the data we will have the qn student and we'll click save now we can see what are we going to do here well we're going to input data on web page and then press add student find a populate text field on web page drag it in inside the for each here we will have a UI element so I click this drop down then I click add UI element here's my web page I want to First have a first name so I have my mouse hover this it will turn red press Ctrl on your keyboard we have now added the first UI element what are we going to write into it well we're going to write from the current student that is a data row so I click this X Q Institute then I go in here and then I will give the header of the data table that column or I can also give the index but I prefer to give out the header it will look like this and again if I need to show you where that comes from you can see student ID save if I go into the qn student once we have run this once you will see the data row here and at first it comes from this header so each one of these rows also have these headers so we can use the student ID first name and last name let's have two more populate text field on web page so I'll drag one more down add UI element and then I'll pick the last name I can move this a first name sir so you can see what's going on and again I can write it in so I just say Q Institute I go up here and then I'll have a hard practice and then first name as that is the column header first name and similarly we do the last name so we create a new UI element at UI element and this one is rather quick because this is just a basic flow and Noah introduced some best practices but once we proceed with this lesson it will get very Advanced and I will of course slow down so here I'll say cune student then I'll say hard bracket I'll say last name like this and a hard bracket end and again you could also use the the index of the columns that is zero index that means that the student ID you could write in zero here without the single quotation marks the first name is one and the last name is two but I prefer to use the column names those ones are more stable and will more rarely change than the index imagine that a person adds in a column then the index will not um make sense anymore we also want to click a button so here I find a click link on web page and I'll drag it in here find the UI element so that will be the add student I click control edit so now we have these three public text Fields where we'll put in the data and we'll click one other best practices that we use UI names that is describing you can see here we use here input text format A123 input text first name that one is better to to rename these we go over to UI elements that is this stack of paper over here and here we can see it pick this input text format AA right click rename and we can call this input text student ID I can also in the same format let's rename this this one was better but since we are using this I'll just write in first name so right click rename and then give them better names like this so now we are done what we just need to do is to have a closed web browser down here in the end and then we can try test the basic flow and here I will have a close web browser drag it in here in the end doesn't matter if it's before or after the close Excel that will close it so then I can click save try to run it now and to do so we click run and we're done with the basic flow once we see this works so we are opening up a web page and now we start to put in the student ID first name last name you can see that we successfully added the first one and it it's visible down in the table below and that one was the second one and since we have three students Karen Lee is the last one we are done we even closed the browser so that was the basic flow let's apply very Advanced best practices to it we want to do a symbol log where we'll update the status if I minimize here I go into my project folder into the students and open that if I go to the students tree we can see that we have a status column let's update with the success message and I know if we have an error right now we will also just update with a success because then it's very easy to do the error handling afterwards so we're still in the students tree and in case we want to make sure that it opens here just save here and then I close then we go back to Power automate desktop so here since we're going to write back we need a helping variable right now we're working in the data table called Excel students we want to write back to the Excel book and let me just show you the Excel data students here that one is sear index that means that the headers row we we don't even have a an index for that in the Excel book in Excel sheet we have the index one and here data table the first row is index 0 whereas in the Excel if we have headers that was was index two index one two you'll get used to it but in the beginning it will be a little bit difficult that you need to add one to it and here since we have headers we want to say if when I write this um this one here and I want to update the Excel sheet I want to add 2 to it so here it's zero but in Excel it's two we will use a set variable and introduce a helping variable so drag that one in before the for each here I will call that one row index and again we will start with the value 2. I try to repeat these things a lot then I make sure that you will remember it if things goes too fast simply just pause or rewind the video is designed for that I also want to say for each one of these iterations I want to add one to it so I drag in a set variable down here I go up here and then I find a row index I will add one to it that one is easy I just pick the variable picker again say row index then go inside the code block and say plus one that will add 1 to it then I can click save then I want to update the Excel each for each one of these so I go up here and then I'll find a right to Excel worksheet and I'll drag that one in right after the click link on web page and before the set variable row index where we add one grid that is important so please make sure it's placed here what do I want to write well let's just say that we don't have a particular error handling we just need to know when it's processed it's a success then we'll add the error handling after it the right modes that will be the specified cell that is fine and what column do I need to update and here we cannot use the headers we need to either use index or letter I prefer a letter since that what we are used to in Excel column A B C D that was the fourth column and then for the row we're using the row index so I click this X and I'll double click the row index I'll click save one thing that we can do here is to make sure that Excel is getting saved for each one of these iterations with an Excel save to Excel and that will save it to the original sheet or we can just choose to save it down here and that in this way if the workflow stops for some reason if we haven't handled an error then we will not reach the close Excel because the the workflow will terminate and that could be a problem we will see later in this lesson how we can handle for every error in the flow let's just have a save document here it will click save again let's try to run it and we know that the browser works because we saw that we even saw the Excel so what we're going to see here is simply just that we can write this log after we have entered the Karen student so that was the first one that was every now we have shown and soon we will have Cam and we can inspect the Excel book first name last name and student and the blob browser will close that's it let me minimize this go to the student sheet there you go we have now a success for each one of these one thing that I also want to do right now we are overwriting the original data it's usually better to write to a new file let's also say that this robot runs over and over we want to lock these Excel statuses right now to a separate Excel book so what I do here I still want to log it to here I can either add an output folder or simply just do it here for now we will do it here because that's easier when we often need to open this in the coming hour also so I go back here so in the beginning I want to get the current date and time so I go up here and I'll find a get current date time and I will drag it in here after the set variable so I can get the Q and date and time it's my system time zone and I'll store it in the current date time and that one is fine I'll click save to use this date time for a variable a text variable so I can use it in the file name and make it Dynamic that is we can use the date Time Each one each time this workflow runs to create a file name that one will be unique we will not need to override it at any point let me show you so I'll find a convert then I'll have the convert date time to text drag it up here here I'll take the current date time have it here I will not use the standard I like to customize it myself so I pick custom and here I'll write four y's that is the year that is the same format you use in Excel if you're used to that if you want to know more just google.net.net custom date time format will also be a link to this in the video description if you want to know more simply just right after me now and this is to say I want the year month days and then I want the hours in 24 hour format so I can easily sort with it then I want to minutes and seconds it will look like this so a very rather long feel free to for example make a hyphen between the day and the time then it's probably more easy to see what's going on this one will be saved in a formatted daytime variable I can click save here and now if I scroll down here into the closed browser let me double click let's choose to save the document s and now our project path comes in handy because it's nice that we have the project path in the variable so that when we use it multiple times we will just use this variable this means that if the project path changes again we can just change the value of the project path in the beginning so right now we say we want to save it in the project path I also want to have it backwards less and so far it looks like this students.xlsx but in front of the students we want to have the newly created formatted date time I click this x here double click the formatted date time and after this percentage change I'll have an underscore that is just to separate these two names so now I have Dynamic file naming for my output that means that if I click save here me run it once more then we're going to fill in these three students here and once we have done that we will have a dynamic file naming that will make sure that the file will never get overwritten so again here we can put in these three students and one trick to Speed it a little bit up because we will use we will try to run these flows a lot today that is to go down to run delay and pick one this means that we will usually have a delay between each action in the workflow of 0.1 second that will be a lot when we work with it instead we now have close to nothing we will only see this delay here in the editor if you run your flows from either power automate Cloud the overview or desktop shortcut we will also have a run delay of one it's nice sometimes when we build these to have these delays so we can see what's going on so let me just click save here that is another important thing there's no auto save and power automate desktop so make sure you save your workflows power automate desktop will ask you to save once you quit but let's say that our computer restarts by accident then everything would have been lost if I go back here you can now see that we have a lock or a date before our file naming that means that each time I run this robot we will be creating a new Excel book and you can see with the data if I open up the original and also choose to delete this click save just to make sure that say this is the original we will not update this at any time then I can close let's do some Arrow handling we can divide these arrows in categories first we have the success that is no error then we can have a business exception that will be when we have something wrong with our data that could be a missing student ID or a student ID in an invalid format but of course also first and last name today we will only work with the student IDs but you can apply the techniques and each one of these categories of data first name last name or even each category of your own data gesture fantasy sets the limit and what we want to do in a real life scenario is to handle every exception that can occur and finally we also have a system exception that means that if a web page or system is completed down or maybe just the buttons missing on input field is missing something that a workflow cannot handle we also want our workflow to handle that let's start by the business exceptions that was errors in the data and let's see what we can do for that so let me go to the input data again here I want to move to the students exceptions here and I can choose to right click rename control C just to copy the name out because I'm lazy I don't want to make errors this is the sheet that we're working in now and here you can see Daniel Chen got a plank student idea we shouldn't persist that but we won't lock that here is a business exception and similarly down here with Peter Liu we can see that we are missing it did it in his student ID so let me just close this and go back to Power automate desktop so right now we will be working in the students exceptions so if I go up here in the set variable active Excel sheet I just double click Ctrl V and there you go we have now said we're working in a different sheet it's that easy so that's why I always keep my variables in the beginning they are easy to change there it's in special especially productive if we're using the variable more than once in our workflow that's that's why it's the best practice to use variables because that way we can just change it up here and it will automatically be updated further down the flow multiple times let's structure this flow a little bit better as you can see we already have a lot of actions and in fact we're using 26 lines of code of course some of them are regions and stuff but we can structure this a lot better so go into the for each let's take the three populate text Fields so click this one with your mouse so it turns gray hold shift in and then clicked click link on web page now you should see that these four will be great then you'll say Ctrl X to cut them out and we will make a new subfloat a subflow is simply just a flow within this workflow that you can call from the main this one is called Main and this is the flow that will always start when we start our workflow so if you go up here I'll show you here subflows new subflow and here we can call this process transaction since this is the Sim the single one and here was the transactions so then I can click save here I simply just Ctrl v i paste it in right now we don't have a connection between Main and process transaction so I need to go out here and then I need to say in the beginning of the for each I will run this process transaction so I'll find a run subflow and then I'll drag it in here then in this drop down you can find your process transaction and then you will click save now we're going to handle the business exceptions and yes that is only the errors in data we want to handle and later on we will handle the system exceptions as well so here in the beginning of the for each let's start by having the student ID as a variable we can choose to have it as a student ID instead of the Q and student ID since we're going to use it a lot this is not necessary but let me show you what we're doing here so here I have the set variable I'll just choose to just for understanding of this lesson you don't have to do it but it won't hurt you so here we'll have the qn student student ID that was the same thing we did before so here I'm just saying that I want to take this qn student student idea and just store it in a variable since we're going to use to work with it a lot I like that now we can use this student ID if I go to process transaction and see I used it here I can just use the variable again not necessary but it will make my life a little bit easier as a developer then I can click save we're now using the student ID here back to the main we are also going to create a status variable and a status message here we will hold if we have a success or an exception and we'll also have a log message saying what went wrong in this case our data afterwards the system so drag in a set variable after the student ID go up here call this status we're going to make this blank so for each iteration that is for each student that we want to have a blank value once we start we'll do that by having a percentage chance then two double quotation marks and then the percentage signed that will be a blank value in power domain desktop then we can click save similarly we will have a status message because I'm lazy click this set variable status so it turns gray Ctrl C Ctrl V now we have two of them then I can just double click this one and change this name to status message so now we are ready so each time we go in here we are creating three variables where we only needed to create these two this one was for Simplicity in the flow we'll see that in a little while and then we are running the process transaction but before we run the process transaction I want to do data check to check if the data is correct and that is even before we start processing data let's create a new subflow for that so I go up here new subflow let's call this data check I'll click save that will be blank so the first one we're going to ask here that is is the student ID blank then we know that we shouldn't process it because it will give us an error in the system so if I go up here then I'll find an if and if asks a question that could be answered true or false here I want to look at the student ID do I find it here and I want to say is this student ID empty so I find the operator empty that will remove the second operator operand because there's no need for that so here we're asking is this student ID empty then I want to update my status message saying student ID is blank oh now I put in student ID here up here I'll have a set variable and drag it in here here we will use the status methods down here and here we will have the status message if this is true and that is if it's empty so I simply just say student ID is blank and then a DOT and I'll click save so once we have done that that check and let me just show you this input Excel data once we have done that check that is this one here then we can check if the student ID is in the correct format and that is we want two letters a hyphen and then three digits and to do so I'll go to my browser go to regex 101 and here a test string so we know that the correct format is this we also have other sorts of formats that could be this we can have a b c four five six that would be another correct one then we'll have a def 789 that will be one letter too much and we can also have a number too much this is just a test um what we're going to do now because now we're going to introduce regular expressions that is one of the things that I want to recommend to learn as an RPA developer because you will use it a lot regex is a series of characters that defines a search pattern that mean we can define a search pattern that only find valid student IDs and then we will use that in our flow so what I will do here is that I will say I want a letter from a to set that one is here here you can see this is one layer my HSN we will have a lot of matches we'll have the N the M the a b c then I'll say I want two letters after each other I'll do it by having the curly brackets now you can see we excluded this so here we have a match here here here then we want a hyphen like this I also want three digits so I'll have it backwards less the digits the curly brackets three and this one here so what we have now here you can see we have three matches you can even see them out here and this is the regex 101 is a great way reg X tester because it's also provide you with explanations so right now we have three matches and it even matches one of the things that we don't want to because here it says well I found two letters and three digits here we don't want that so we want to say only if it's the start of the line so if I go up here and make a hat we now have our reg X pattern where we can check if this is a valid format we will use this you can choose to be even more specific if you want to check for more arrows but let's stop here and say this is sufficient I'll go back here and then I know that if I'm in here if this is empty well then I set the status message as student ID but if it's not empty then I can do some data check on it which I will use with for with reg X sorry I'll have an else I'll drag in the ills here and what I'm going to do is to find a pass text and drag it in here what text do I want to pass I want to pass the student ID so I click this one here and double click the student ID what text do I need to find and that will be the regex pattern so I'll Ctrl V that regex pattern in then I'm telling power to make desktop this is indeed a regular expression what I then need to do that is down here in variables produced reproduce two variables we have the position and that is if it finds a match it will say in what position of that string is it in we don't really need that so and take that but we have a match and that is if we find a valid student ID in this student idea and then the match will get stored in the match variable that means that we can check afterwards if this match got a match inside it then we know we have a valid student ID if it doesn't got a match then we know that the student ID is in in the minute format so then I can click save yeah so now I can go here and and say if this match is empty then I know the student ID is not in the correct format so find an if and drag it in here so what I'm going to do is simply just say the match if that is empty then I know I can set the status message and I can say well the student ID is not in the correct format and then I know that if I end in here I can say that if the match is empty then the student ID is not in the correct format so let let's grab this variable up here Ctrl C go down to end place your mouth there Ctrl V paste it in then I'll double click here it is just because I'm lazy again and here I'll say and I can even use the student ID student ID is not in the correct format and a DOT and now we'll just need to ask if this status message got something in it then we know an error occurred up here so I'll go over and drag in another if in the end and then I will say if the status message isn't empty then I know something is wrong here but before we do that another best practice is to make comments that is for more difficult parts of your workflow you want to make a comment that could be this one up here so find a comment a comment is again ignored by runtime and when you use a comment to describe something in your workflow have it before the actual thing it described you probably know it from programming and here we say checks if the student ID is in the valid format by using regex like this and here now you can see this commented here it will get ignored at runtime so and it's a nice way to document your flow however use it only for the complicated part that will give you or your colleague a hard time when you come back to this flow don't overuse it and start to document each action because then it will get even more confusing so right now we will have this status message isn't empty then we want to run a subflow called business exception which we will build now so you go up to the subflows you will have a new subflow and here we will have a business exception name I'll click here so in this subflow we will have a variable called status where we will lock that here's a business exception and then we will pick the status message go into actions find a set variable and drag it in here I will be calling this one status we already defined it it was blank in the beginning of the fridge so I'll just say this and here I'll say business exception like this and then we will give in the status message yep so um right now I can just click save here so we can also add other things to the log like a date we will not do that for now so if I go back to the data check here down here if this is an empty that means that we have something in the status message we will run the business exception subflow so find a run subflow yeah and drag it in here what shop flow do we need to run we will run the business exception right here and we will click save now we have built a data check we'll also set that if we have a business exception we will run the business exception flow and the subflow means that we run the subflow and then we will come back we haven't run the subflow out here in the main so let's do so so here again run subflow we will do that before the process transaction and that is because we want to check if the data is valid before we run it so here we will run the data check I'll click save so when this data check comes back we want to ask is the status empty if so we want to make sure that we want to make sure that we only run the process transaction when the status is empty and that is we find an if we will drag it in between the data check and the process transaction and here I'll say is the status is that empty if that is the case you can run the process transaction right here so then I'll drag it in here I'll also need to say that if we have run ran this process transaction that is if we reach this state down here I know we can have exceptions tied to these public text Fields but let's forget about them for now and make sure you stick because we'll also handle them in this extensive power automate desktop lesson so go up here and then you'll find a set variable drag it down here click the X have the status and now we can say well we got a success we reach this state go back to main so now we know that we can either have a business exception or a success also go into the right to Excel worksheet because right now we're not going to write success anymore we will write the status so find the status here and then we will click save now we're done let me also save it then we will kick it and we will see that we can now handle business exceptions and we can even handle different types of business exceptions so we have one web detective it's blank we also have in in the valid format we could of course also check first name last names and every other data thing we can even make it more extensive for the student ID for now this is nice feel free to add more data checks or even apply to your own flows so now we're done let's go to our student sheet so we have this one working now there you go we have now made an even more advanced locked and you can see two different error messages now we also want to handle system exceptions that could be if we cannot perform an action for example the public text field because an element is missing let me close this one here and I've created another sample page this URL you will find in the description as well so here you can see that we missed the input Fields but we're also missing the other ones so let's say that our flow experience a problem with the first input field of course we could also do a check if these are present in the beginning but let's keep it simple copy the URL up here so Ctrl C and go back to your power automate desktop flow then in the set variable URL change it to this new ul and then click save so right now we have a problem with the first populate text field because we don't have the input field and we want the robot to lock that go to subflows and then click new subflow we will call this system exception and it will be similar to the business exception so I go up to actions I'll find a set variable and here I'll say status and just like before I will say business exception and then we will put in the status methods like this and we will click save so right now we have we have done nothing but we will do the check here in the process transactions so what we want to do we want to say if we have a problem up here in the student ID then we want to handle it and yes again we could make the check to check if these ones were present in the beginning but see this as we had a temporary problem with this populate text field just for this line so then I can click on Arrow an arrow means that what should happen when we occur in Arrow we can do a lot of things here I just want to log a message to the status message so I go up to new rule set variable go into this X status message and here I'll just say couldn't populate the student ID input field we will still be drawing in a room so we need to say we're drawing an error here that means that our workflow stops if we don't do nothing but we will surround it with an on aerial plot it looks like this you can see that we now have an on Arrow we can see this for this Blue Shield what we want to do here is that we will find an unblock Arrow drag it in here in the beginning we can give this a name that will be catch process errors so what are we going to do here here I want to do two things first I want to run the system exception so I take this new rule I'll run the subflow which is called system exception but I also want to say we don't want to draw an error now now we handle it we login it to the system exception so we want to continue the flow run and go to the end of the block and that is the end of the unblock Arrow so here I'll click save and I'll take all of these I can take them one by one or I can click the first one hold shift in Click the last one and then drag him in like this that means that if I get here I'll ask just as before is the status message empty in that case we will lock it as a success so we will find an if and drag it in here so is the status message is that empty like this then we will lock the success let me save it and let's try to run it again right now yeah we will be getting only system exceptions and you can discuss if we want to also make a check that terminates our flow or probably maybe retry this so that we try to open this page like um three times if we don't succeed then we're not going to do it so right now we are trying to perform it I'll just fast forward until the end and then we will inspect the Excel that's it I didn't have to fast forward at all we have ran it let's see um flow in action so open up the new one here and if I double click here we can see that we are now having a business exception five times and that is let me show you what I did wrong here I open up the system exception and here I will have the system exception I choose to include these in my videos because as you can see I always also make mistakes I'm just a human like you don't knock yourself when you do these I will of course update the video and let me just show you that this works so I'll run it again and if we run inside from a shop flow it will still run the main I'll fast forward to this has RAM and we'll see the actual actions that's it and you will see that if I go into the next Excel book now we have the system exception and we're separating because first we do the business exception check here and then we do the system exception saying that we cannot populate the student input field now we can handle two different kinds of exceptions we have the student that I have the business exception and the system exception while this Excel thing is a great way to do simple logging you can easily lose structure especially if you want to add more features to the lock such as a date so let's create an advanced log that will not lie in Excel I'll close this one here and I'll go to my file explorer let me open up a new tab let's go to documents here I'll create a log folder feel free to replace your log folder wherever you want so while right click here I'll say new folder let's call it power automate desktop Lux do not delete this is important otherwise sometimes they're getting easily deleted and let me also fix this e here like this then we will shift right click copy as path so we're copying the path for this on my machine then I'll go in here let's design our log go say right new and then a text document this one we will give the same name as our workflow in our case let's just remind ourselves we call it best practices demo if I go up here and then I'll say best practices demo in case you don't see this extension dot txt then what you're going to do is to go up to view show file name extensions right now they are not there otherwise we are like this in case you have Windows 10 you also just need to go up to your menu click View and then file name extensions so what we're going to do here is that we're going to change this extension txt in a little while let's first open it it's a bit more easy to work so what do we need in our log we will need a start time we will also need a workflow so we comma separate them we will have a subflow is it our main that we are in is it our process transaction where are we we also want to say in which action I'll be using it and then we want the comment this is a great log template that I learned from a very sharp power automate um person called Shaggy his channel is is right up here in the right corner please give him a subscribe but come back to this video so right now we have a lock I can close and save it then we want to change this extension so I go in here and then instead of txt I will say dot CSV like this it says am I sure yes and here you can see that I'm opening it with a weird icon here that is notepad plus plus I'll definitely recommend you to download that now if you don't have it it's free it's called Notepad plus plus there's also linked to that in the description you can use Excel to open CSV files or even notepads but we're going to leverage the notepad plus plus features so what you want to do when you have download and install it then it's just to right click and then you want to say open with make sure you pick the choose another app and then you go find it here if you don't see your notepad plus plus you'll say browse a choose an app on your PC like here go into your program files and then you find a notepad plus plus directory choose this one here say open and that will make it up and say always we are always opening CSV files with this notepad plus plus now you can see we have opened it so we have designed it we can now start and create a lock in power automate desktop so we go back here first thing that in the beginning we want to lock this workflow name so that is one thing that you always have to do have a set variable in the beginning call it work flow name and ours is called best practices demo in that way we make the connection between this workflow and the log that we want to fill in so right now we have um this workflow name we also want to store the log directory we have that in our clipboard so I'll drag this one in here and here I'll say log there that'll be a new um variable Ctrl V here you can see we have our log directory in our clipboard then I can click save we can start to lock our first make our first log message so what do we want to do I want to say which subflow am I in and what action am I in that means the number here and then the comment later on we will add um the date and it will look this so I'll have a set variable here and this one we will call log list and again all credit goes to Shady shaking I've not to say that I improved it I make it better to work with this best practice template um and yeah it's pretty awesome so thanks again shaky so here we will have the lock list and we're going to create a list here I'll say main that will be the subflow that we're using then we want to say this one is starting at action one here we want to lock that and we also want to have a some sort of a message also in single quotation mark and here you can say something like workflow starting we can even add a name if we wanted let's just keep it rather simple so these are three of the things that we want in so now I want to add the time and workflow name to it let's start by finding the time and then we will combine this I'll click save I scroll down to this fridge then a dragon set variable in the beginning of each for each I'll call this time I'll also make this empty so it will look like this and then I will click save so we are just resetting a Time variable nothing in it right now we will start to fill in let's create a subflow so I'll have a new subflow here and this one will be called current time then we can click save so we all we already took a date time later earlier in the flow which we used for the Excel file we will use another date time format for our luck so let's create that we can combine it so let's find a get current date time here we are getting the current date time and let's just save it to a current date time variable we will click save we already have our um formatted date time in let me show here we convert it to a format a Time variable which we use down here in the closed Excel so if I go in here and then I'll have a convert I'll find a convert date time to text here what are we going to convert that will be the current date time like this it will be in a custom format now we will have it in a mall dock friendly format it will go something like this and then we'll have the milliseconds let's save it into the time variable so I'll find it here so now each time we're going to use the time we will just call this current time um subflow and get it there so we will have a right to lock and that one we will have here have a right to lock and what are we going to do here we're first going to get the current date time so we have a run subflow and we'll drag it in here so we're going to use the current time here once we get this we can merge the two two lists where we can say we want the time and the workflow name in one list and then we want the list called log list we created that in the main we want to merge these two that will be our luck so find a merge lists here and the first list that will be we will create that manually that will be the time variable and the workflow name here and we will have a hard bracket and a percentage sign the second one that will be the log list here like this and we will just overwrite the log list so we now have the log list that we want to print to our CSV so let us click save here then we want a right to CSV file and we will drag that one in here the variables to write that will be the log list and again please let me know in the video comments below what you think of this does this help you what can I improve and finally give it a thumbs up if you like what you see that definitely helped me and my channel a lot thank you so then we want a name file path and here we have our log dear so let me scroll up to find out we want to say the log deal then we have the variable called workflow name that's why we call it the same name as the workflow then we say dot CSV we also want to go to Advanced and here what we want to do is to append the content since we're going to add this data over and over and let me just scroll a little bit down here we also want to separate it by a comma and let's just make sure that we do that so we say our CSV is separated by a comma that's it now we're writing the log here over and over each time we do it we only called it once that is up here but we will apply it to our flow later on so right now we're going to say we want to after we we have have this set variable called log list we want a run subflow here and here we want to run the subflow right to lock and then we want to click save right now we're only going to make one log entry so we can choose to stop our workflow after that we can use a breakpoint click here and see that it turns red that means that our workflow will stop once it gets here but it's plenty of time to have the log written and that's just what we want to check now so right now we should have written in the lock it will only say the time the best practices demo main one and the workflow starting if I go in here to the best practices demo you can see that we have just that here we have a time we have a workflow name we have the subflow we have an action and a comment that's it now each time our flow runs we will append the content here so pretty handy isn't it now we can just stop the flow and we can add further log entries so we can see that this also work so right now let me go up here what we need to write to a lock is this set variable lock list and then this run shop flow called right to lock so click the set variable hold Ctrl n Ctrl n and click this one say Ctrl C now I have what I need in my clipboard let's go down here so in this for each I also want to do a log that is for each one of these students I will say new student processing so I'll click this variable Ctrl V and now I paste it in what I need I just need to change this lock list so if I double click here and here I'll say I'm still in the main and each student is starting at number 19 that is indeed the log you can also argue that it should be 21 up to you and here we will say new student processing like this so now we have one log entry we also want to have for example we can say right here we can also say we want a student we want the result in the lock so here press Ctrl V I can move the Excel one up above and then I'm just going to open this one yeah and here I'll change one to that will be 29. here and then we'll have a log message saying something like a student processed with the result and let's just have a colon and a space and let's combine it with the actual result so I will let's just have a space and then say status that will be my status variable where I have logged in the actual result so right now we also have this in the lab and let's go down here to the end Ctrl V again we are in the main we can choose to have these logs in our subflows we don't do it for now but feel free to do it it will work just as the same just copy these ones in here so here we're saying in there 14th we will say workflow ending like this and we'll click save let's save it and before we actually try to run it the clever thing about using the notepad plus plus for these locks or any other log program with live logging that is it doesn't lock this file once our flow runs and that means that we can easily do live logging we can inspect it to see if everything is going on is is there arrows in the flow all these things so once I maybe I can do this I can click run and then yeah of course we have two business exceptions again and we will have three system exceptions Where We Are we cannot find these input Fields free feel free to change the url to the original one that will also work there so right now we have created an awesome lock and more importantly we have also encountered for a lot of exceptions we have documented everything keep in mind that your flows will be slower now because the more actions you add to your flows the slower they will get not a problem you should always do exception handling logging if that is needed and if we go again to our lock here the best practices demo you can even see that right now we have added the new things if you want to live view this because notepad plus plus lets you view this in real time you simply just go to view monitoring tail F and that way we can do live log viewing here in notepad plus plus let's now do some input validation that means that we want to check if our robot write something we want to check if that is what we told the robot to to write in a lot of cases if you have an unstable system you might see that some letters are missing and we want to check for that and then if it's not the case that if if it's not written the result that we want then we want to retry x times so let me close down the log and we will go to our browser go back to the original one here we will take this URL I will copy it over let's go to Power automate desktop and let's create a new flow which we called input validation playground I like to have these ones here because then we don't need to change our entire main flow that we built sofa so so far it's been a long day so here the input validation playground I have now have an empty one let's just say that we want to check if we're going to write the correct student ID so let's have a static student ID student ID here and here I'll just say ac789 that will be our static student ID then and these arrows come and goes don't there's not a problem that you have made just close power automate desktop will continue that is some of the things that we see as power ultimate Developers I'll then drag in and launch new Microsoft Edge and here we want to grab the initial URL which was up here so make sure you copy that one here and paste it in here so we want to run a loop that go over and over and um if we and then we try to populate the the the student ID and we want to extract it then we want to compare these two and then we are done if that is correct if they are different we want to run it over and over let's do one by one so here I want a loop condition let's just have it go over and over that means that this one here will just run because true is always equal to this will be an infinite Loop and I can run it and test it or you can do it but we will of course change this never make an unlimited Loop so the first thing we want to do here in our Loop that is to populate the text field with the student ID so here I'll say populate text field on web page I'll create the student ID here and what do I fill in I fill in the student ID variable that we just created up here I'll click save but also because we don't want to forget these things I want to rename this just as we did before I know we did it but always make it a good practice to rename your UI elements and variables like this so right now we are populating it we can also extract it to make sure that because we're populating it here then we want to extract whatever number or letter that might be in here so find and extract data from web page and make it in here for this to work we just need to have our web page to open then this live web helper will occur go in here inside the student ID right click extract element value and pick this two three four three and take the text we have chosen it and I click finish we're saving it in a data from web page variable I'll click save because this one will of course run as long as these two are equal to each other and let's have a breakpoint here in the end just to inspect that we can input the student ID and we can extract it here in the data from web page and then we know how we can work with the data from web page here we open up a new browser we input in the student ID we're extracting the data and now we pause the robot we can go over here click stop remove the breakpoint for now go into the data from web page and here you have it so now we have extracted whatever is in the field and now we can start comparing it but keep in mind that this is a data table that means that to get in here we need to have the second row sorry the first row that is the zeroth row index zero and the First Column that is index zero so 0.0 in dated table terms because it's zero indexed we will click close here so right after their extract data from web page we will have a set variable yep and here we will have the extracted student ID like this what do we write here we want to look in the data from web page then we want to go into the First Column so I'll say zero and sorry the first row that is zero and the First Column that is also zero so 0.0 the rows is first and then the columns then I can click save so now we can correct the loop condition because we want to this flow to run as long as the student ID is different from the extracted student ID that means that we try over and over I go up here sorry double click here and then we're going to say we want to look at the student ID if that is not equal to the extracted student ID so I delete this extracted student ID then we can click save here now to see this works to see that let's mimic some errors so before the extract and after the public I'll add another breakpoint let's try to run it and right now we are running we populate the student ID and then our in two seconds when we click continue our workflow will check is this the correct student ID but let's add a number just that could be an error we can also delete it if you prefer it like this then we will click run um and now we're continuing because the student ID is not correct let's make another error click run we will check and it will run over and over until it is getting correct of course we want some sort of a maximum let's just try to click run now now it will check and it will find out well this is the correct student ID that's written in that we ask the robot to we can now stop let's move the breakpoint so we saw this work but we also want the max Loop counter because it's not ideal to have this stock let's say that's a non-stable system our workflow will be stuck here forever or for a long long time so let's have a set variable before the loop condition this will keep track of where we are in the loop Loop index let's have it the value one and then we will add one to it for each one of these iterations so go down here and then you'll say you can also pick it from the variable picker which I told you that we should always do so let's do that and then we'll do it here the only times I don't do it I shouldn't do it that is probably sometimes when you make a larger code block and you need a variable India because then you also need to delete the percentage sign so that will be another source of error you might not want to do it there so now we have this Loop index one by one let's say that we only want to try three times and then we want to have a system exception so what I do here is that I double click up here so I will do this first one to say student ID I can I will gather it on one line I'll say student ID it's different from the Excel and here's what I said then I need to delete this so first I'm just rewriting this whole thing and this and the operator equal so now I'm asking is the student ID different from the extracted student ID if that is true then we'll run our Loop that is the exact same thing as we wrote before I did this because now I can combine I can look at the Loop index because I also want to say and I like to keep these in capitals then we can see that this is an operator then I'll say add and here I will say Loop index is less than or equal to 3. both of both of these needs to be true and then if that is true we will run this over and over again we can try to have this to check this to have a break point here run it and now we are populating it let's let's do just to see that this works three times three arrows and then we should finish because the loop index will be four yep that's it so this works we will of course try to throw an arrow where we will um say if if we have tried three times then we want to throw the arrow saying that we cannot type it in let's implement this input validation playground and then we will do it in our main so click this set variable up here hold shift then click it down here Ctrl C we will be using this in our process transaction subflow of our main so let's go back to the main I'll go back to domain here and we need to go into the process transaction so right after um we have tried to populate this student in we want to have a region where we check for the student ID this is a practice that I'll use a lot check that whatever we told the workflow to write in is that also what it did right in I'll have a region here and here we can call this check student ID and we will click save so unfortunately we cannot manually throw an arrow so what we instead can do is to have a label and in the end of our block arrow here we will have a label that's it if this doesn't work we want our flow to jump here and here we'll just say end of uh on block arrow like this so now we will inside this region we will have our check Ctrl V we just build the data so here we will check if everything is correct with the student ID so in the end of this check student ID we will ask is the loop index equal to 4 that means that we have tried this three times it didn't work and then we can say we can log a status message and we can go to this label down here so in the end of the check student ID have an if sometimes power automate desktop hides these ifs it'll be up here just to expand this that's not a system in it so um yeah so make sure that it's between this blue green and yellow and here we will ask is the loop index so yep is the loop index equal to four if yes then we will set a status message and say that we couldn't type the student ID correctly so what we do here is that we will have a let's set variable like this have it in here and here we set the status message so so status message and we will say Curtin type student ID correctly something like that we'll have it here and after that we will go to this label down here so um what we will do here is to have go to right here and drag it in here and that will be the end of the unblock Arrow I can click save and to make sure that this status message gets locked as a system exception that will be here then we will run the subflow system exception so here you will find a run subflow drag it in here and choose the system exception because that's what it is I'll click save click save here we will not test this but this will work more than welcome to do so add in a breakpoint and do these weights let's talk about weights because let me show you here in our here we have I've created another web page with a delay that means that each time I run this you will see that this form has a built-in delay of 6 to 12 seconds that could be a parking or slow web page rather and here we go we have it and we need to account for that we will create a playground once more grab this and we will create another playground so I'll say wait playground and open it now um we will again navigate to this so let us just have a launch new Microsoft Edge and paste in this that will open up a browser then we want to populate a text field so which is what we do in the May so I'll have a public text field on web page choose to add a UI element and this is the one with the delay that one will be here and let's just pick a random student name a student ID like this so now let's say that I run this you will see that it will take 6 to 12 seconds to put type in the student ID and all flow says well we already type in for some reason it send it this student ID here but it will not be typed in here and that is really not nice because in that way we are not waiting for this form to load what we could do the simple solution would be to add a weight here have a 12 second wait before we populate anything let me try to run it again so now we're waiting 12 seconds you and I are together for 12 seconds and in that time if you haven't subscribed to my YouTube channel yet please do so I'll be making a lot more advanced power to make desktop videos here we go we had to wait but instead of a static weight we can use a weight for web page content that's more efficient imagine that we have a thousand or ten thousand students and instead of waiting 12 seconds we can say wait just as long as this form has to load for example 8 seconds in average that will save us around 12 hours we also have flexibility because we can set up specific events or triggers to happen before we start to fill in it will be more robust and because sometimes these 12 seconds might not be enough and here we are making just say wait for this and then continue it's also nice to do error handling with this because it will get a lot easier so what we do instead of this weight we will delete it find a wait for web page content and drag it in here we want to wait for the web page to contain an element what element it is that so I'll add the UI element pick the entire form here here control and pick it click save here we have the form student ID first name last name add student that is fine now we can try to run it and what you see here is that we will wait to continue until this form has loaded once that is loaded then we will continue to flow and populate the student ID here you go this will be the correct way to do it we can also let me open here open up the open wait for web page content we can fail with the timeout Arrow we can say I want to fail this one look for it for X seconds for example one second and now it will fail and then we can handle that Arrow so right now you can see that we wait for one second and then we're throwing an arrow here it says timeout has expired you can even account for that as well let's um go in here and we can either choose to not fail with the timeout error here we could get stuck if the element that we want to check for is not loading so probably you want to do like I don't know 100 or something and then it will time out and you should handle that Arrow as well so let's just pick 100 we will click save here so copy the wait for web page content and populate text field on web page press control and click both of them then Ctrl C go back to your best practices demo so what we want to do here in the process transaction in the beginning so before we do anything else that is before we populate this we want to make sure that this form is there so here I will control V paste it in now we can open up the wait for web page content because we can have a timeout Arrow here and what what will that look like and that will look like we have this on Arrow and um so we will just set a drone arrow that will be called by this unblock Arrow we created earlier and then we will say the input couldn't load so here we'll have a set variable we will have the status message either do this or again let's practice it so we always use the variable bigger so here we will say input couldn't load we'll troll the arrow that will be called here so that means that we will go to the end and continue so right now we have implemented the dynamic dynamic weight over static weights as well work use in RPA acts as a centralized storage for tasks ensuring efficient workload balancing we can easily monitor tasks we can make sure they comply with our SLA we can prioritize we can do everything what we want to do is to split our flows into two a dispatcher and a performer let me explain you what this is to take our current flow we want one flow that is the dispatcher that will be to say what data do we need to work with here's an Excel sheet so we would take this Excel data and add them to a queue one by one so each student here is a transaction item then we will have a performer that will be where we take each one of these items in the queue one by one and then performing by doing this it allows us to spread these transaction items across multiples butts that can run concurrently or we can prioritize things and in the end we can easily watch what is going on let's try to do so so what I want to do and maybe we should clean a little bit up here in all our browsers so I'll do so every link is in the description below so now I only have this we go to Power automate.com and what you need to find is the monitor then the work cues down here here we're going to make a new work queue so you say new we give our work queue a name I will call mine students and then we'll click create so this is the queue that we're going to use um for our workflow with the students let's add a few manually after that we will of course use our Excel sheet to add the students to the queue so I'll say new now we'll add a queue item we can give it a name that is a describing name that we want the queue item to have it's nice because then we can easily track them let's say I want something like this and then I want to comma separated um queue item data so that will be in our case here it could look like this we wanted comma separate because then our power automate desktop robot can easily split this so I do this create and now we have a Q item if I say see all you can see this queue item we have a name and we have a value what I want to do is to of course process it with our flow that will be our performer then we want to change the queue status and have some processing notes let's go create that we need the word queue ID and that is this one you see up here so Ctrl C copy everything from this a to F you probably have another number so go do that and go to the best practices in the beginning we go to main up to this set variable we will have another set variable so here let's just have it in the end of these four and this one we will call where qid I'll go into the value Ctrl V to paste it in so then we go down instead of a for each we will have a process work queue items so I'll find a process where Q items it serves almost as a um for each but here we just take one item from the Queue at a time so drag it in before the for each for now the work queue we created a variable for that that one was called work queue and here we can see we produce a variable so each time we take a queue item it's called where Q item I'll click save and then we want the end to be right here so what we can do that is this end what we can do is simply just click this for each delete this and then since we're going to use the other end we can just delete this end here and now we have a nice process where Q items we still need to fix both the student ID the first name and the last name coming before from the date table now it comes from our queue so now we need to split this workq item because this work queue item comes in with this value so we need to take the value out of the workq item and say index 0 that will be the student ID one the first name and two the last name so let me go here and then we will find a split I will drag it in here what text do we will need to split that will be the work queue item but click this arrow and choose the value the delimited type that will be common so we will choose custom and a comma and here we will say work you item no value like this then we'll click save now we just need to go to the student ID first name and last name and instead of this we will have the voic Q item value here it will be zero that was the first value let me copy this so I click save here go to process transaction the first name that will be index one and the second name that will be index 2. like this so now we need to update the actual where queue items so we will say either success or an exception because we cannot use variables inside the update work you item we will make an if just asking is this a success or not right before the right to Excel worksheet so what I do here is that I want to say is the status equal to success yes or not if yes then we want to update the working item as a success else we want to do an exception so find an else up here and drag it in here so up in actions you will find an update work queue item drag it in here so now we know which success we'll update it as processed and here we will give in this state just like this click save similarly we will do that in the else so I will control C copy this go down to the end Ctrl V double click to open it and instead of it processed we will have a generic exception I'll click save now we can delete all the Excel activities so I can have this right to Excel worksheet delete that I don't want to write it to excel anymore I want to use my queue delete this close Excel up in the beginning I will delete the read I'll delete the set active I'll delete the launch and I can delete the set variable active Excel sheet let's try to run it right now we're still having the flow with the system exception now we are opening up it's still a system exception but that's fine we will see that our queue is able to handle our system exception and categorize it as a an exception with their exception message so let me go to my browser you need to refresh the queue here and here you can see it says exception and it says the system exception that it couldn't populate the student input field that is great we can now use our queue but yes it will get a little tired if we need to manually add these to the queue imagine that we have a thousand transactions so let's see how we can do that first let's add the initial UL I'll grab that that is the first one we created it's just a little bit more fun to see that that works so I go up here um in the set variable URL paste in that then click save so now we want to make sure that everything works and we want to make sure that everything works where we add the entire Excel book sheet to our work queue so let's do this first first we need to move our we can do this in several ways here we have our project folder I have my input here let's copy that one out here I go to my OneDrive this could also be SharePoint or whatever cloudflow we have such as Dropbox I'll right click here and I'll say new folder and let's call this best practices demo you could of course add another folder and when you go into production with this and then I move in here and I'll paste in this Excel and what we need to make sure is that it's uploaded to OneDrive as it has now then we go to our power automate Cloud we need to open up another instance of power automate Cloud I can just right click here and duplicate tab here we want to create a flow so when you are here at the home click create we can choose to automate this say that we want to add items from folder each morning or each time we get an email we can do that let's just pick an instant Cloud flow for now here we can call this dispatcher we will manually trigger our flow and then we will click create the first thing we need to do is to get the students out of the Excel and then we will add them to a queue which is our queue so here you will find a list rows present in a table the location that will be OneDrive OneDrive file and that will be I'll find the best practices demo here I will find the students and the table you can see here it's called students 100 table 2 table 26 and that is because let me show you if I open this one here if I need to find out which one we are going to use that is the students exceptions I can go in here take the table design it's called table 26 you can of course rename it if if you want let's just stick with that for now so we go here we pay the table 26 I'll click save so now we have each one of these rows we will iterate true I'll pick a new step and then I'll find and apply to each yep we will take the value from up here and then we will add each one of these rows to our queue I'll take a new step and then we will have an add a new row pick the one that's called Microsoft dataverse like this and we need to put it inside here so let's drag it up here it needs to be inside the apply to each the table name that will be work queue items find it here the name of the word queue item well that will be we created an ID for that in the this rows present in the table so let's pick the student ID we did that as well before then we need a work queue ID like here what you do here is to have a forward slash say work queues then you want a parentheses start we need to grab the word qid so let's move back to the queue Ctrl C copy this one in go back to the second one here and and the parentheses then we also need to say what data do we need to input so here in the input well we set the student ID we set the comma first name and we say last name like this you can also have a status reason that is we want to say these ones are cute so let's click save here so what we're doing what we're doing here with this Cloud flow is that we're reading from an Excel sheet and then we add them to a queue which in our case is the student queue let's try to manually test it and here we would have five different students at to the queue in a few seconds so this is the way to do it if you want to scale it let's go here let me refresh it here and here you can see that we have added these ones to the queue since this Daniel chin missed a student ID you can see that this one gets a longer one that will just be the work queue item that is fine for now and even this one here that was our exception from the beginning so now when our workflow processes these ones here they will it will handle it with each one of the difference exceptions tied to it right now we will have the business exceptions and those ones will be locked so let's try to run it once more now we will Loop through five of these so let's see how that works here's our first Q item that one looks fine and you'll see that now we might do a check if this is was an exception so we might have done the check it will take a little bit longer but it will hopefully get updated in the queue it will we just saw it worked and um we will have three or four successes and then our web browser will close like here let's go to our queue that one was here if I refresh this you can see that we now have three processed we have a an exception here that is student ID is blank that's right we also have this student ID is not in the correct format that's also right what is nice with this work use is that we can come back to here say that our workflow has ran then you can easily come back here and inspect what has going on with the different queue items for example this one here um we can inspect what is wrong with the Peter Leo so and we can even choose to retry if we want that build that in our flow but let's not over complicate things what you need to understand here is the benefit of a queue that is that we can now monitor everything well we can prioritize these Q items so say that some are more important than others then we can do that every automation should be built with the config the benefit here is that we can easily update the parameters in our case those were the set variables in the beginning and also that a business person can easily update these values say that he or she wants to change something in our workflow I don't really want to share the code because that way he or she can make errors not intentionally but just because it's not that experienced compared to me or another Advanced developer not to say that we are more worth as an experienced developer we just have different competences so we'll make a config let's do so by going to our documents we had this power to make desktop logs do not delete so let's create a similar one I'll call this power automate the desktop config do not delete like this so um let's open it double click it and right click new Microsoft Excel worksheet here we will call this one best practices demo the same as our workflow double click to open it we will have one sheet here rename that so right click call this one constants like here we will make two different columns the first one will be key and the second one will be value those ones equal to our set variables in the beginning of our workflows see the variable name as a key and then the variable value as the value so what do we need here well we need to logged here and we need to RL and let's inspect what else we're going to need go to the main go up here so here we are going to begin the lock deer here we also need the project path um but since we're not going to use it anymore we use it with Excel we can also delete it only keep it if you want to update the Excel as well then we need the UL and the word qid let's start by this logged here so I'll just copy this one here move back here paste it in here the URL I have it here here Ctrl C I will have it here and we also have the work queue ID the order is not important and the work uid also had that one but now what we want to accomplish is that we don't need to have the workflow say it's either in a different machine or not the user then we can just use these values here for our config so we have these three ones here I'll save it so now they're named the same one and the intuition here is that we want to read it in an s in Excel then we want to convert it into a custom object which is key value Pairs and then we can refer to those ones by their keys and get their values out let me show you how that works the first one here let's just get the config folder so I shift right click copy as path I move back here we need another subflow and that one is called new subflow here and we will call this one config here we will have a config path I recommend to always stick with the same otherwise we can of course change it here like this like this one and this one can also if you're going to change these places I rather prefer to have it in our main in the beginning it doesn't matter variables are used acrossed subflows so now we have this one here and then we need a VB script and the first one I'll say VB script Ruby is just a script that will run and then it can do some more advanced things that we can do in power automate desktop now we need a VB script I'll also link to that in the description below that will take it to my Google Drive what we need is this script in here I can inspect it here it's simply just a script that opens up an Excel it takes the config path that was the variable that we just created it also used a workflow name that we created it read the constants sheet then it takes do a little bit of data manipulation and it create a custom object or create a Json which we can convert into a custom object so copy this run VB script here paste it in here like this instead of the actual VB script output let's rename this to config s Json here and we'll click save so what we also need is to convert this to a custom object we'll find a convert and here you'll say convert Json to custom object we use a custom object because it's easy to refer to that within power ultimate desktop so the Json that will be this one the config Association up here and here we will say config acid is an object that describes it a little bit better so we'll click save here then we can also go we should go into the main so here I'll click the main so we're going to use the config right before this lock there so what you just do here is to say the Run subflow have it here and that one was the config like this we can try to run it so setting a breakpoint here at the Lock there make sure you close the Excel try to click run it will be rather quickly to initialize this and what you can do here is to go over to your config SDS a custom object open it and here you can see that we now can refer to this config as custom object give the key which is logdia UL or word qid and then we will have a value back so let's do that so right now we're using a config instead of these set variables or we will do so let's have this breakpoint removed so what we're not going to use that is this set variable log there delete that and that will give an arrow that's fine you can see the error is over here in the right to lock we can also delete this URL and the work queue ID don't worry we will fix this so what we will do here is that in this launch new Microsoft Edge I'll double click that we will use the config as custom object here and here I will say UIL because that's what we called it in our config sheet and let me just copy this so it's easier to dip here we will have the word qid I hope I spell it right so it will look something like work queue ID you this key needs to match the one that we did in the Excel sheet similarly to right to lock double click here and this is the locked here so delete this and say logged here we will click save so now we have created our config we have nothing in our queue we can test if it works but if we want to test that if this works we can test this dispatch again and we will have new Q items that we can have our flow to run with so right now we're adding this this will be added to our queue then when we start our flow we have data to process and we can see that it works if I um refresh this we can see we have five new Q items well they are the same as this one but still five new that we can process let's try to run the best practices demo again um we are getting quite advanced we have now built a config and again please do it in all your workflows where you have input data especially if you want to change these if you want to update if you want to share them across departments it's very easy to have a centralized place and OneDrive or SharePoint where business person can update these things that could be a URL or an email address for the lock read Max retry attempts everything we need there so that's it and yeah you saw everything work and you can see everything work if I refresh here now we have except two exceptions and three processed again that's how easy it is to use a config we can go even more advanced here that is instead of each time we need to copy this code in for config I will just have a new workflow where we build a config I'll call that workflow every time my workflow runs those that needs a config so let us go to Power ultimate have a new flow this will not be a playground this will be the actual build config that I will use in all my workflows so I will maximize this here so what we just need to do is to go down to best practices demo find the config here Ctrl C copy this one go down to build the config here now you see that our workflow name doesn't exist that is the one that we use in the VB script if I open here you can see that one is up here and that is because we haven't um we haven't initialized it yet and also here this config path all my configs are here that's a nice way to have a centralized place in case we also want these to change this variable should lie in our main workflow let's just not over complicate things so I want to call this config workflow each time I want to build a config that means that I want to have an input variable I'll call this workflow name that will be at the kind text let me copy this because I also want it to be named externally so that one will come in and then this config as custom object will go out I have an output and right now since this exists we will be getting a warning saying do we want to merge these two that will be fine copy this and this one since this is a custom object pick a custom object down here and click save and yeah that was the merge thing here pick it though this flow we will just call this from our main and then that will work so I will click save here and what we do here is that we can close the build config we can go over here now we can delete this config flow I'll delete this one here and right now you can see that we have um we have some errors because we cannot find the config as custom object and there's a subflow we cannot find that's fine so first one we don't need to run a subflow anymore we will run a desktop flow so I will delete this run subflow then I'll have the Run desktop flow and I'll drag it in here so I will run the desktop float called build config that is the one that we just created I'll pick that one the workflow name well we have a variable for this oh this and you can see we produce a variable called config as custom object I'll click save all our errors disappear so very very very nice and what we just also want to do here is that we can test it but I promise you it works if you want to test it run the dispatcher one one more time and then test it last thing is to go over to this one's here we have some duplicates here some UI elements that we don't use what you can do here is to click these three dots removed unused elements click delete and then we only have the elements that we're using in the actual flow your next lesson is here want to learn more advanced power automate desktop then you should join the I love automation Discord Community we are more than 8 000 RPA developers networking and helping each other it's free and your invitation guide is right here
Info
Channel: Anders Jensen
Views: 37,172
Rating: undefined out of 5
Keywords: Power Automate Desktop, Advanced Users, Best Practices, Workflow Optimization, Config Building, Advanced Error Handling, Advanced Logging, Advanced Input Validation, Dynamic Waits, Work Queues, Dispatcher, Certification Guide, Career Advancement, Microsoft Power Automate Desktop, Robust Workflow Design, Handling System Exceptions, Handling Business Exceptions, Dynamic File Naming, Reusability in Workflows, Workflow Efficiency
Id: QjrxLPg_TdI
Channel Id: undefined
Length: 127min 18sec (7638 seconds)
Published: Tue Jun 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.