logo

NJP

Flow Designer Error Handling ServiceNow | How to...

Import · Jul 03, 2023 · video

welcome back and in this video we're going to be taking a look at error and Link in Flow Design so we're going to look at that little switch and that little section of the bottom with error handling but we're also going to look at some try logic and simple value to use so join me on the platform let's go by next [Music] in today's video we're going to be doing some error handling stuff in flony's island but before we really get started you know what to do ignore you're not yet subscribed please consider doing so if you are smash the Bell icon share it with all your servicenow buggies let's dive into the tool let's do a bit of a demo okay so what do we have here let's go through this so I've created a flow for the purpose of this demonstration quite simply what it does let's walk through it right so when an incident is updated well when a state of an incident is updated it's gonna start doing this flow logic so it's going to look up for an incident record it's actually going to look up to see have I got an incident where the parent is the one that triggered it it's also going to do some weird stuff right the kenoid um of you will notice this it's going to look up that record but where the state is New and the state is closed so we know that is not possible why am I doing that well because I thought it would be a bit of fun but two I want to force an error the whole point in this is to see how we handle errors in flow designer right so I want to create that error don't do this in real life um then what we're going to do is go and update an incident record say boom I found it so we're going to update that parent when we found it but of course we're not going to do that because we know it's never going to be found so what we've got at the bottom here and you may have noticed it but never really play with it is this error handling switch now what does that do in short when we tick that it allows us to run some logic in this section underneath here to handle the errors so you know when you when you run an error a flow before or you've seen one in the execution it's got a big red error at the top right and we'll show that in a minute um and it just kind of fails and does nothing well this allows you to say Well when that error occurs do this in this section and you can do multiple things you know you've got access to all the actions you have done in the top section so if you're a coder I guess this is like your catch section that'll try and catch block if you don't know about those go and read about the model something in the description however in this error handling section it'll it we've got the same capabilities we have um in the top bit up here but it's specific to when an error happens and in this section here if you move over to the right hand side we've got the error Handler so we've got these um or this error status object with these attributes that kind of input into that section that we can then get at so in its simplest form what I've done here is I've created a log and I've said log where um login error to the system logs and call it error log found and let's just remove that and what am I putting in that I'm putting in error Handler message okay which is the same as this over here this is really simple stuff the one thing I do want to point out is in the error handling section underneath you've only got access access the ability to add 10 different activities in there 10 different actions so just be wary of that and we'll come on to what you can do to get around that in a bit but let's just save this and let's just see what it does so when I reactivate it no let's just test it right so when I run this that first action action number one is going to error at least I really hope it does here we go error so this is what I was talking about before the error that you'll see at the top error completed error Court but now you see what down here look complete that call Action in the error Handler so this log has been uh created down here we see logs no record found of course it's not found and nothing's got a state of New and and um complete let's get rid of that let's take it to the next level right the next level here is we've now output a log which is great it's in the system locks but once if we want to do something a bit more fallacy we can create we look here we can create a subflow a specific error Handler subflow um to then call and this is an architectural decision type is how would you set up those error handlers across your platform do you do it based on process do you do it based on product for example you might want to have an error Handler for incident or problem will change is it all the same error Handler you do it based on scope so perhaps you might create a new application you have a specific error Handler for that these are all things that you need to consider and be aware of and have those conversations about okay I don't think there's any right or wrong answer there are some some considerations but it's it's just something to think about because the downside of not thinking and having some kind of standard policy or architectural policy best practice whatever you want to call it on your platform is that all developers or Consultants will do their own thing right um and I'm going to be honest the reason I'm doing this video because a lot of people won't even do the error handle a bit right we're very good at putting try catch blocks or error handling in our code and script includes but in here it's kind of all what does that do how does it work so this is one do this right but I will say there are other videos on YouTube um around this right and and there's probably far more detail than I and I just want to get the message out there is to start using it start having a play see what it does right anyway what was I say we can create our own its own subflow so I have done that so I'm gonna I created a specific error handle subflow okay and I'm just gonna put in the inputs of error handling code so that's an integer and the error handling message and again this video isn't really around how you create your subflow um but I'll show you how I've done that anyway so let's just save that then we'll go and have a quick look at that subscribe so what's the one by call it error Handler neat title hey right Herald this is very simple so this is a subflow which takes in two inputs which is the error code and the error message integer and string and the right mandatory simply quite simply what it's going to do is it's going to create an incident so we're going to assign a credit incident to the assignment group of servicenured admin team because why not short description description caller your flow died yeah because why not so again this is a simple concept this is about this is my error handling policy on my platform my company my service no company decided this is how I'm going to handle errors yours might handle them differently so have that discussion there are no fancy things you can do in in here again I've seen some great videos where you can before you create the incident record you go and look at the flow context ID so you can actually put a bit more information in the incident record that says hey here's the flow that triggered it here's the sys idea of the flow that triggered it and hey there's a click link that I can take you direct to that so go and check those out that'll that'll give you that that um extra info but I wanted to do something simple so you guys could say hey it's not that difficult let's go play we get that so now we've got a log and the error Handler and it's when the error occurs it's going to kick off this subplot so let's um did we save it I don't know let's do it find out we run that again again we're expecting it to error okay we run the flow we have errored the loggers continue but now we've got the error Handler of the subplot that's ran but remember there's only one activity in there okay let's go and see subflow context great record oh look there we've got our incident so let's have a click on that it's great at Arrington should we open it yeah may as well we're here anyway okay so now we've got the insulin created error flow details no record varied code one okay so and this is assigned it for my team so there we have it a subflow error hunter subflow that we called from apparent flow so now we've taken a look at that error handles section on the bottom how does the try logic come into it I said that right at the start how do we apply that well let's go back and have a look at how we can adjust the flow to use the trilog okay so this is our starting point we've got our flow with our error handling section now if we go up here with flow logic we've got try okay you might not have noticed that before but why don't you try that what this means really it's like again I've mentioned it before because I try catch logic in in when we're doing coding right it allows us to try a section of things but if there's an uh an error occurs then do something else right so try a section of things in here you've got a little plus and if an error occurs then do that so we know an error is going to occur here right so let's just move some stuff around so let's put that in there do those an update record we can do that there okay now let's have a look at what we've done there we're saying try to look up the incident where the parent is all that triggered it and the state is something that's never going to happen we know this is going to hurt right but if an error occurs in that step which is this tri-step then update the incident record right so update the incident record other update record here we go uh let's update the parent record and we'll update it with um let's put some work notes in there work notes is um oh no okay okay let's just for now let's save it and see what happens okay answers or puzzling in the comments to what you think is gonna happen so we've got try we're going to try something if an error occurs upload the instant and we've got the error Handler still active right let's go ahead and run this test okay now we're finished are we still going to error we have we've got error here ah but this time it didn't run me around right even though we've got an error before it was triggling the trigger before it was triggering the error Handler now it's not but it is saying if never occurs then go into this so does that mean we need that error Handler in this occasion probably not right so if we what happens let's just validate that theory if we deactivate that save it again meaning you don't really need the error Handler what we'll expect to find now it's pretty much the same thing right then we're going to look at one more thing before we finish up yeah it's not run and it didn't run before okay because we've switched it up the one thing I do want to draw your attention to as well right is I guess what we're doing in this instance is we're trying to handle the errors before the arrows are caught in our error handling right so we're trying to I'm gonna do it before um before the last measure of the um error Handler if we go in here we have this section here or this tick box here don't fail on error so I'll tell you what let's tick that and let's give that a shot see how that changes let's turn the error Handler back on let's see what happened again a lot of this is let's just do something simple like this and just see how it works so let's run that okay what do we think here we go so what we've done now is it's not errored it's completed that's interesting so in this instance our error Handler has not worked because we've told it don't create an error don't fail on error don't don't create an error for this instance right but instead it's not found it not errored therefore the update record does not happen because there's no error in that try the last thing I'm gonna try no pun intended let's go back like let's duplicate this action and we're going to move that into here so that all last thing to happen right we've got a don't fail on error we've got an update after that what do we think is going to happen let's check it out again no error let's take a look at this hang on let's see if I can get that over there take a look at this look up record we know that's not going to work properly because we've made it not work two states that don't have any relationship to each other but it now runs the update straight after right but it doesn't run that if our error occurs because there is no error interesting what does this all really mean well I guess it means that one flow designer has error handling capability two it's actually quite simple to get your head around three I would urge you to go and create yourself a perhaps a test flow and just muck about with a lot of different capabilities you've got what it means to you right four is consider how you can apply that across the platform but your own platform that you got if you're a customer or if you're a partner the project that you're perhaps working on five if there is is there any platform policies that are already in place that you need to be aware of in terms of error handling but number six whenever you're working on a flow even if it's a new one you're creating or one that you're inheriting or one that you're having to work on consider the what if what if something happens at this stage what if an error does occur do we need to do anything with it and start asking those questions when you're in a kind of story refinement as well so I hope you found it useful if you haven't yet subscribed please consider doing so smash the Bell icon give it a like share it with all your servicenow buddies but the other thing is make sure you check out the service dubs podcast with Jamestown tonight every other Wednesday where we talk about all things services until then I've been rushed a mess [Music] foreign [Music]

View original source

https://www.youtube.com/watch?v=QoRIssYPINY