Power Automate for Desktop Configure Exception and Error Handling

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone this is Daniel and in today's video we're going to take a look at Power automate for desktop configure exceptions and error handling so in the last eight videos we looked at a whole bunch in power automate for desktop and you should have gotten familiar to start building your own at least start testing it but today I want to focus on how do we handle those errors because you know that there will be situations when an existing flow is working just great suddenly started giving us errors so I want to focus on how do we handle those also how do we start Gathering our own logs so we can start troubleshooting it in a much more step-by-step process so stick around there's a lot to learn but first here's my intro video [Music] thank you so let's get started and if you followed my videos you know where I am this is my power automate for desktop it is tied to this environment and this environment has the pay as you go as your subscription what I'll do is I'll go and start a new flow and in my new flow I'll go ahead and give it a name I'm going to say exception and error handling demo we'll go and create it so now we'll actually go into the main console and start testing this whole error handling now in one of my previous videos you must have seen me launch an Excel spreadsheet which is a very specific spreadsheet and if you've noticed this is what it is I've got a sheet of spreadsheets the one I've actually been using is the financial example so what I'll do is I'll actually come over here and I'll go and grab the link of this financial example like the full path of that right so I'm going to go and highlight that and I'll do a control C and I'll just keep it beside just so if you don't miss it what I'll do is I'll also go and create a go to launch and in my launch I see launch Excel spreadsheet and I'll go and keep it over here and in this action I'll actually go and say that I'm going to do it with a blank one but I'm going to open up a very specific document so I she got that entire link ready I don't want it up to the file level I just want to go and create it right up here perfect and I've got the sample spreadsheet open it up and I'll make it visible everything is good and I'll keep it save it quick test will actually go and remember as good stewards go ahead and save your flow so you don't miss anything right always keep it keep that and once it is saved do a quick test run it and once you run it on the bottom over here you will see that that Excel spreadsheet will load in fact it's opened up right on there let me go drag it anyway here Excel spreadsheet loaded on the bottom you can see that at the Excel spreadsheet is there so we know that this flows so far works but in that scenario what happens if that spreadsheet has disappeared from the location how do we handle those errors that is what I want to troubleshoot and let's actually go and make that change I'll come into this action and I'll just say Okay instead of this inside the spreadsheets folder it's actually going to be in the demo folder all right you and I know it's not that it's actually in that subfolder but now we are going to reenact an entire error situation so if I go and click on Save now right now if I go into run there will be an error something will happen it's not able to do that on the bottom it's actually saying that there is error and it gives me this and if I want to actually go ahead and open this up this is the information that it gives now this error details there's just too much information too much information for me to even understand but the two things that I really like is right here it is telling me where the location of this error is so it's telling me this is in your main flow right in action one and what is action one it is launch Excel I love this error this immediately tells me what is wrong with this and then after that the error message the error message that we see failed to open Excel document so before we Deep dive into Gathering our logs and doing all this information let's just spend some time in what all I can gather directly from this action so on the bottom do you see this on error not all the actions has this on error there's only specific ones for this type of situation if you're going to go and touch a data all going to do any crud operations create Run update delete those type of operations then those usually have this on error so when I go and open up the on error there's a lot over here to absorb and we'll take it step by step so first of all right on the top there is a beautiful action available for us to you try right which is retry action if error occurs and that is always the first thing you want to do is when in doubt retry it always retry it but the beauty is that once I toggle this on it is giving me more options how many times do you want to retry it and what should be the interval between each of the retrines so for example I want to go and at least retry this once and what I also want to do is that when we are retrying it go ahead and put in like a two second delay between because you just know that there might be something happening on this machine that the Excel spreadsheet just hasn't opened up so you make your gut instinct on this it's like okay I think I need two seconds or in these are actually running on some of your heavy duty say server type of environment where you want to have it a little bit more delay go ahead and use your best estimate on that go and maybe say five seconds all right this is a really good play to go ahead and actually do some initial steps of troubleshooting so what I'll say is actually I'm going to at least try two times and the two seconds interval is perfect right so I'm going to at least do that all right I'm going to click on Save and immediately did you notice something on that action now it is going and giving us this error handling logo this is perfect because now just by viewing the main flow itself you know that okay in that action I've already gone ahead and assigned an error handling process so let's do a run all right now I'm going to click on run over here which you and I will see that it's actually going to go and do an attempt you in fact we'll see this little blinking type of a feature that just means that it's attempting to launch the Excel and after two tries it will go ahead and give us an error over here so now let's go and take a look at what this error works all together right so if I go and open this edit up it looks exactly the same all right it tells me what was the location it is action number one and what was the message so it doesn't give me a whole lot of information as to what happened how many attempts did I do no it doesn't give me any of that however at least it went ahead and tried so now we know that in a troubleshooting scenarios at least the delay part which is on the on error the delay part that did not work so now we need to focus our attention on this section over here right in the all errors also keep in mind that if for some reason the top one hasn't worked you can still keep it on or you can go and toggle this off I'm talking about this retry action and errors you can go and turn that off but remember this is something we're trying to replicate for the actual production type of scenario so we want to go through the steps I'm going to go and keep this one toggled on as this but the next thing I'm going to do is focus my attention on this throw error well once an error actually occurs I want to go and throw an own error that makes sense to me so far in this throw error I'm going to select that and I'm going to now click on new in the new I want to go and select a variable I want to actually set a value of the variable so when this little action comes up I'm going to double click on that and I'm going to put in a bar for variable error message and in the error message what is this message well I'm going to actually go and type in something so let me go and put this on tething up I'm going to say something in effect could not launch the Excel spreadsheet check to to see if D and I want to say location well how do I go and grab that location see whether on the top that location was actually saved into the Excel instance and that's a variable that's automatically created see over here on the right the flow variable well if I go and now click on the variable section all I got to do is grab that flow instance so I'll go and select that and then I'll end with saying something in effect that location is valid just to make sure I type that in correctly and that is good so now I can go and click on Save and let's go and reenact this entire situation again we're going to be doing this a few times okay so I'm going to click on run it'll go into the launch Excel it's going to go and attempt that at least twice with a delay of two seconds in it and then after that when the error comes up we will go and take a look at our error message over here so therefore the error message is coming in and it has been captured so whenever we click on that right over here if I double click on it you will see that could not launch the Excel spreadsheet and then it tells me to go ahead and check the location so we're actually making some progress the errors are coming up over here okay now what we did over here was a one-time scenario where if an error occurred in in this specific step and if I go take a look at the editor it just creates a variable and it saves it over there but I want to first of all capture more information and I want to set this as a repetitive thing but if any error happens go do something and for that a best scenario is go ahead and create a subflow because that subflu can be very Dynamic one but it doesn't care which action it is we'll just trigger that and we'll go and follow the exact same steps for any actions and it will just work so let me actually go do that first right the first thing we're going to do is come into a subflow and I'm going to create a new flow and I'm going to call that as capture no spaces error info right I'm just going to call it something simple like that and over here we start going and Gathering all the errors what I'll also do is go ahead and add first a comment so I'll just search for something called comment I like this comment area here under flow control drag it move it over here drag it and drop it and then I'll put in this text which says when the test outcome is negative this subflow creates a list with the case info a sends it to a temporary test CSV location and marks it as fail basically we are creating our own log file all right so I will go and click on save that way we've had this common data we know what it's going to do now I need to go ahead and get all these errors when an error happens I need to go and grab these errors so what I'm going to do is I'm just search I'm just searching for something is there something called error yeah actually in the flow control there is something called as get last error so you know what let's just go take a look at this flow control there is a bunch of good things that are over here first of all the comment the comment is what we just added then there is a way for ending it exit a flow all that but here you see that there is something called as get last error on block error and even the label keep that label in the back of your mind we're going to revisit this in just a few minutes but right now this is what I want get last error so I'll go and drag it drop it over here everything looks good for now it also went in and generated its own variable so I like it I'll click on save for now and I can see on the right side and the flow variables the last error Pieces come out so we have got a way to now automatically go and get the errors I need to go and start saving it we talked about it as a CSV file so we've got some options first I want to save it in a variable so I could put it in a data table type or I can go and put it in a list type for this one I just want line by lines items coming and getting all the errors dropping it into a line by line item so a list one works fairly well for me and so that one is in variables so on the variables which is right on the top I'm going to go and get a create a new list and I'll drop it over here I'll change this name to something like this oh I got two extra percentage it's going to be a VAR error log list I'll go and save it another important thing that we need to capture errors is the date and time so let me go and see do I have anything for current date and time there you go I just went and started typing in current space d there is already a variable there's already an action available for that so I'll go and drag that drop it over here here everything else looks good I want to make it for the system time zone which is what is the time zone running on this machine of yours that is perfect for me you've got some other options by the way you've got system time zone and specific time zone I'll leave it at the system time zone and the variables produced is called this current bar date I mean current date and time I don't have an option to change this by the way this is the hard variable that's already set you don't have the option to change it but it makes sense so I'm going to go and click on Save and then after that we're going to start adding these items so if I just go and X out of this one go back to our variables now in the variables we are going to add an item to this list so again click on it drag it add it drop it I'll go and get what is this item that I want currently I want the current date time so let me go select that select it and then add it to a list well we actually only have this one list which is the VAR error log list so I'll select that and click on Save and so it's already finished the first item is we went and first created the list but I'm going to get the television when did this happen it's going to go and save that over here next thing is actually go and save what is that error so for that I'm going to go and add another item I'll drop that item over here and then what is the item that I'm adding that item is going to be the last error see the last error variable is coming from the get last error action so I got that last error select it save it and then this one is going to be added to a variable of the bar error log list so I'll go and save that save it over here and then finally I want to go and get this data from this variable list and write it to that CSV so I'm going to go and say write to CSV see write to CSV file perfect I'll go and drag that drop it over here and that one is going to be the variable that we did the initial writing and that variable is the VAR error log list that's my variable the file path let me go and decide what that file path is going to be um I'll go and make sure I just drop it over here in this location I like that so I'll go and select that I'll put it over here that that's going to be my file path and finally exit this subflow and that's exactly what I'm going to search for is exit sub and there you have it exit some flow drag it drop it and over here we basically don't have to do anything else that is what it is so I'll go and click on Save now and we just gotta go and make sure that we've actually go and assigned this subflow to run so once it's done we go to our main launch this one click on on error we've been actually gathering this variable so that's fine but I'm going to click a new rule in the new rule I want to run a subflow so in my subflow this is what it says run subflow that one is going to be well I only have one subflows that's going to be capture error so I'll do that I'll go and click on Save and now again save it as good stewards and then I'll go and do a run so in the run you and I already know the first steps of the two of seconds delayed not gonna work but in the process you will watch it'll switch over to now the subflow and there's a second section that's happening so there you go went there and did that and it's now giving us an error well what was the error let's go take a look I think I know what the error was um we did not actually give it a full name so I'll go here I'll go give back um here I'll put it a backslash and I'll just say error underscore log dot CSV save it now let's go do another full run so I'll do a full run goes to the main side and the main is going attempting launch now it will switch over to our subflow it went through it properly we still got an error now that error is coming from the main one but if I were to go open up my folder yep right there the error log is coming in it's one kilobytes so if I open this up now it is actually starting to gather all of this we are building our own log files successfully and it's giving us all this information see timestamp came in perfect then we know what again what was the action what was the flow and then it also gave us the error so we are making some amazing progress over here all right but here's another problem that's happened first of all the error still comes up so how do I get past this because I don't want to end this as an error anymore because what happens in my real world scenario is that I might have more actions after this I just want those actions to skip and then go and just end it well how do I do that so first the fall I'm just gonna first pretend that I've actually got some actions over here I'll go and do a display message so I'll search for display and there's a display message so I'll grab this I'll drop this over here I'll say test message one you can do a control C control V paste it Ctrl C Ctrl V right there all right and then after that I'll just do a control C Ctrl V that way I can put in another message just to show as if we have some actions over here and how that's going to work all right because in the real world scenario that's exactly what will happen you'll have one main action and then after there's some sub actions and then at some point something will fail so we're just trying to recreate a real world scenario so I'll do that test three test three all right and we're done over here now after this we can now create that scenario where say the error happened on the top I want to go ahead and now jump straight to say The Last Action but that last action should be some type of display message which is telling me hey and error has occurred which is why the flow just ended unexpectedly so for that one too I will go ahead and now just put in a error message right over here that error message will be say of a type big warning and I will say something in effect that the error has occurred all right and then I'll go and put in a little bit more information over here it says hello and errors occurred no worries we have captured the message and saved it in your log file and then after that we'll go and click on save all right so this is neat but I know what you're thinking you're saying Daniel there's one thing missing how do we make it jump from that one straight to this one if there is an error occurring because if there's an error card I don't want it to go through these steps I want to jump it directly over there and for that we use the label technique so watch this all right I'm going to go up over here and I'm going to delete this and I'm going to search for something called as label this is how the label works now there's another one when Google cognitive service called label detection don't get confused it is a flow control one so I'll drag this I'll drop it down straight over here and now you've got to go and give it a label name so I'm going to say throw error message all right that's the one I'm going to go and give it over here directly that and in the launch where you think that the error is going to happen in the launch go back to your on error and then right over here flow run name click on that and over here there's the option for exception handling mode drop down and select for go to label in the go to label it will give you the options and we've only got one which is the throw error message we just added so I'll select that I'll go and click on Save and right there you will see that it's showing up it's very important that this is right before wherever you want to display that error message all right so again good stewards we'll go and click on Save and then after that now that I hit run it will successfully run it it will go and capture a log file but we should not get this error message on the bottom hopefully but let's go into a run so we click on run we know that this Excel spreadsheet is not in that location it does two attempts let it go through that once that has gone through it will go and switch over to the sub flow because that is one area that we added subflow went through an error message directly came up so it went so fast that I was still talking but the error message came up this is the error message that you added see we came back to the main one the subflow random capture info area it finished it switched over to the main one it skipped all these other messages it noticed the label once so it went and gave a message but see on the bottom over there we didn't get that error pop up so the flow is still running and if I actually click on OK it will come and say status ready everything is good so just to be sure if we go and take a look at our error log location there's the file that just created I open it up it has captured all of this error logs in a very systematic way also there are other type of actions which will do that so for quick one that comes to my mind is when I go and do say a SQL one all right I've got something called execute SQL statement drag it drop it when I put it over here see it also has on error not all of them do but every type of these actions like I mentioned anything that has a create Run update all of those current operations or anything that you stuff with they tend to have these type of errors and if you've noticed they're all very similar if I go and toggle this on same thing that we tried over here for the launch XL over here here same option go ahead and add rules set the variable you know the one we just captured over here to save it run a subflow then you can do a throw error you can continue with the run like it's giving very similar things that is why I just picked one to show you how you're going to actually create that because the same thing applies to all the other ones as well so this is pretty neat because you have now professionally and logically found out the way how to go ahead and capture all your errors and build your own log file things such as the date and time stamp getting an outline of what the error was and in this case where exactly the error occurred which Step it was a very professional way to start doing some troubleshooting and in this example I focused on the Excel action but I also ended by showing you that hey either SQL execution or any other actions that does like a crud type of operations the error handling is the exact same you go through each of the exact same Steps step by step and call the same subflow to capture your log information so hopefully this video was helpful to you and now hopefully you have a good overview of how to use power automate for desktop and if you've got any ideas for other videos let me know in the comments below and I'll build them just for you and as always keep using power automate for desktop with power automate cloudflow hello hello hello so if you like this video go ahead and click on that subscribe button and smash that like button also if you have a few extra seconds can you go and put in a comment either say something nice or give me ideas for my next video and until then see ya
Info
Channel: Daniel Christian
Views: 8,056
Rating: undefined out of 5
Keywords: Power Automate for Desktop Configure Exception and Error Handling, power automate daniel, daniel christian power apps, power automate, power automate tutorial, exception handling, power automate desktop, power automate error handling, configure run after, flow error handling, error model in powerautomate, Power Automate subflow, power automate retry action, power automate retry on failure, power automate desktop label, power automate labels, power automate desktop logs
Id: HjrDVypW7Mw
Channel Id: undefined
Length: 21min 16sec (1276 seconds)
Published: Mon Feb 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.