Exception Handling in Power Automate (Flow)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone this is krishna napo business applications mvp welcome to my channel today we will be discussing about exception handling in power automate in the past we have discussed about how to handle exceptions in power apps those who have not got a chance to look at that video i have included the link for that video feel free to go and watch that today we will be learning what is an exception in power automate how to handle and how to get the exact error message back to the user before any further delay the business case for this video is maker should ensure that flow is executing without skipping following steps if any issue or error encounter in the business logic what exactly that means is in power automate if the flow engine encounter any error while it is executing the flow the flow will get terminate from there and when we see why should we need to learn exception handling no client is ready to see their entire business process got failed because of one record or value is not in desired way as i said if it encountered error at one place the entire flow will get terminate and the rest of the business logic will not get executed another issue is flow engine will tone up the flow if it fails continuously last but not least end user will never be happy to see the flow failed notification from the flow engine periodically let us see how to handle exception handling in power automate on a very common issue in day in day out development i have a power app for all my release management business logic of this app is as soon as the team submit a release management cycle the app has to submit a record to sharepoint list as well as it will trigger a microsoft flow to send an email to the manager of the selected team lead let us see how it will work if i select a lead wherein the manager is not associated i have selected sye as the team lead and provided the release date and as part of the team members i have selected and myself when i submit the business logic of this app is to add a record in sharepoint list and if we come back and see the sharepoint list i have added one record budget tracking and this is the entry and let us see how the flow is performed the flow i have created as like this powerapps and this is where it will read the lead email id and i am getting the profile of that provided lead email and then i'm getting the manager of that provided lead and then i'm sending a email to that uh provided lead manager so when we see the result out of this flow is the flow got failed at manager while receiving the manager the reason is the resource manager does not exist or one of the queried reference property object not found what is that exactly means is that when i go to azure active directory and check whether psy has any manager associated with that user or not he doesn't have any manager mapped at the active directory level so what the flow got failed but unfortunately the user will have no clue what happened exactly because we are not able to send anything back to user how to handle this kind of a scenario is if we see the classic way of handling exceptions in the development model is they will encapsulate all the possible code where they could see a possible exception as part of try and then they will handle the all the exceptions as part of cache and they will write finally block to ensure that whatever they want to execute whether there is a exception or not there is no exception the final block will definitely get execute so how we can replicate as part of this power automate is in power automate we have something called run after we have to configure run after how do we do that is first you identify where we could see the exception and then the next step click on this menu icon and select configure run after it will show a set of options that is successful has failed escaped has timed out which means that whether this send email functionality got succeeded or failed or skipped or has timed out i want to execute my next step which is a compose statement okay now that we know how to handle exception let us implement in our flow and see how we can handle that exception successfully now to this flow what i will be doing is i will be adding a next one step in between the user profile and finding the manager i am adding a step and select on control select the scope scope is a control where i can pack all my possible exceptions into one block and then write a exception on top of it and then catch the exception if there are any exceptions encountered on those set of statements now let me rename this as try and then i want to move this back to select that and move it up this one also so if i have any exception while fetching the manager i cannot send a email so now i have to write one more scope to catch the exception if the exception there as part of the catch i want to see what is that error i am getting as part of my try block now what i will do i am going to write a compose in this compose i want to see the error message out of this dry block so go to expression say result of try now i will get the exception in a json format now i need to read the json i need to convert the json to see what is the error i have to add parse json path json here my input will be compose output and here i have already copied the here i will be generating with the sample json format and then what i wanted to do is out of this i need to see what is the error i am getting so in order to do that i will be creating one more variable as error message where error message as a string i'm renaming that as error message now i will update that variable with the error message say variable append to string variable here error message i selected here i will say message as part of the json okay now i got this error exception handled which i am getting as part of my previous json string now that i have handled the exception if there are any i will be adding one more scope to ensure that my flow is executed with exception or without exception in order to do that i will be adding a condition and i will check my error string has in any data or not the length of my error string is not 0 which means that there are some exceptions and i need to inform that to admin so if it is 0 then my flow got successfully executed i will say i can say this one is here as flow got executed successfully in case if that is not zero i'll have to send an email to the admin team stating that for now i'm sending myself stating that exception are you there so this is how i can send an email to my admin team now that i have completed my flow with exception handling all i have to do is now i know that i have to configure this step run after this click on this configure run after whether this try is success has failed if it is success i don't have to worry about it so i will say ignore if it is hash fail has kept or has time out i need to execute my catch block and then this final should execute whether this got executed or not whether if the if the scenario is a success scenario the catch will not get executed so this will also be skipped so always remember here whether this is skipped success or any way i need to execute my finally block whether the catch is skipped or not skipped i have to ensure that whether it is success has failed skip or timed out i need to ensure my final block is executed now that we have implemented the exception in our flow let us execute our scenario one more time saying like again budget tracking version 1.5 now again i'm going to say psi and then i'll say release notes as bug fixing then same 25 and then there is now i'm just clicking on submit now if i go back and validate my flow the flow got executed successfully even though my manager is not available for the selected lead if you see this try got an exception but the exception has handled properly as part of my catch and also it executed finally when i come here and see it got executed properly the exception is clearly shows that resource manager does not exist or one of its required reference property object or not present because we have already noticed that manager for psy was not updated by the admin so it is showing me the error as resource manager does not exist and then in the final block what we are doing is we are validating whether the length of the error message is zero or not since the error has a value the length will be false and it comes over to else case and it send an email as like this i got an error message email as stating very clearly that exception in sending email to manager so this is the failure case if we submit a release management with the manager value existed for the lead where the manager is existed now if i submit this and when i refresh it's still running if we come back and validate this flow this time my try got executed successfully because i have manager defied defined for my name wherein my manager is psy and it happily sent the email as hi so your team member krishna scheduled for release since that the try got executed catch will not get ex will be skipped and then though the catch is kept it will enter into finally block and now my error message will be zero so the length of the error will be true the length of the error is zero so this condition is true it went on to success case and it's showing as flow executed successfully [Music] the development tip for today's video is while implementing the flow i have copy pasted the sample json format as part of generate sample json format how did i get that go to any of the existing or completed flow and then copy the output of this compose statement wherein what we are doing here is if we notice as part of this catch i am getting my result as a json format and if you see the output of this is a json that is the same json we will have to copy to generate the sample json format now i will copy this output and then as part of here i will be adding one more pass json pass json and say here generate sample paste that output here and say done that will generate the sample schema and then it will be whatever the output it is that is how it will just read through that output so this is how i have generated this output i wanted to cover as part of a tip so that i so what i have not explained while creating the flow hope this tip will be helpful to you guys while generating the flow to render the json that is how we can handle exceptions in power automate i hope you like this video if you like do like add your comment subscribe to my youtube channel for all further notifications
Info
Channel: Krishna Vandanapu - MVP
Views: 7,312
Rating: undefined out of 5
Keywords: Exception handling in Power Automate, Power Automate Errors, Flow Exception handling, Flow Error handling, scope, Exceptions in Flow, Manager email in Flow, Try catch in Flow, microsoft automate exception handling, microsoft flow exception handling, flow exception handling, Exception handling in pwoer automate
Id: 8R_nTzsP_0Y
Channel Id: undefined
Length: 16min 19sec (979 seconds)
Published: Mon Nov 23 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.