logo

NJP

Do the Following Until Flow Logic in ServiceNow Flow Designer

Import · Sep 04, 2023 · video

in this video we're going to be playing about with the do the following until logic in flow designer what does it mean how can you use it let's find out probably [Music] hello and welcome back to my channel in today's video we're going to be looking at do the following until logic in flow designer but before we get started there's two things I'm going to pick on number one is the YouTube stats still are telling me there's 90 of you that are watching this are not yet subscribed that's naughty it's naughty please go ahead and do so it makes a massive difference to the channel the second thing is who came up with the name of do the following until I mean it's logical I get it it makes sense it's human readable it's where we're going with flow designer but can you imagine the marketing meeting they had around this guys we've got this new logic what should we call it well it's kind of like a while loop and we do stuff until something finishes let's call it do the following until come on could I come up with a snappier title surely enough said let's get in see what we saw the buyer I thought we'd start over on the servicenow Dockside I can't think of a better place to start this gives us a bit more info about what it actually is but it also gives us an example this isn't the example we're going to use but let's have a look because I'll be able to explain it a bit better for you so what we'll see is in servicenow we're going to have this this logic that's called do the following and until I gotta think of a better name I can't say that constantly um but but in this example it sends a daily email until an incident is resolved so here you can see incident is created that's the trigger in the flow do the following until wait one day look up incident send an email so every day it's a look of incident send an email until the condition is met at the bottom incidentally resolved so that allows us to instead of doing something like a scheduled job send out an email reminder a an email every day or some kind of subflow that we trigger it allows us to do this very simple contained um array of activities um I guess within a flow until it's met we can do some fancy stuff with it now the example we're actually going to pick on is approval reminders so let me just dive over to servicenow and what we're going to do is we're going to flow designer but we're going to do approval emails right or approval reminders so consider this scenario and I've done another video on this it's just a good example I can think of but consider the fact that we've sent out an approval and we want to constantly remind the people um that we've sent the approval to but hey you've got an approval to do now sometimes we might do that scheduled job right and loop through and say for every outstanding approval records every day have they been sent um a reminder if not send one and we get up to three reminders for example I've been there before we've all been there um but in this case we're going to use the do the following let's do the following until logic so I'm going to create a flow this is Vancouver by the way and we're going to call it uh do the following until test demo let's get a bit fancy demo and I'm just gonna not do anything else you should put descriptions of course you should so what we're going to do here is we're going to look at when the approval record is created so I can never remember which table is sys approver underscore approval underscore approve approve approvers um this one approval is it yeah let's go with it approval record and in here what we're going to do is go straight away uh we're gonna go flow logic here we here we go oh I've got the giggles now do the following until here we go do the following until we select that and that gives us this do the following until so we've got a plus in there so we can add some actions until these conditions are met so until trigger record approval record is it state state is approved okay so that's going to run let's just click that so it's easier to see that's going to run whatever we put in here until it's been approved now we could say approval is created we probably should approval is created and um state is requested or something right well you probably should do that let's do that state is my laptop's going a bit slow I need a new one um is requested okay Okay so we've got our basic flow here right so now what we're going to do is what should we do should we send an email so what we could do is we do action send email right now what is this going to do um it's not send email send email there we go but what's that going to do if I do that what would that actually do so we're going to send it to let's see approval for um is it approving document ID approver there we go approver and we'll just say um approve this okay and there are other all right let me just mention this there are other ways to send emails from flow designer this isn't the way I choose I'm using this for Simplicity and for the speed of the video because no one wants to listen to me waffle if you want to see the other ways that you can send emails from flow designer check out some of my previous videos I'll put an annoying link up if I remember to do it right what's this going to do do the following until right it's going to send an email until it's approved however what we need to do first is perhaps put in some kind of wait timer right so perhaps we need to put in a wait timer so wait for a duration of time so then what we can do is say wait for you we can put in a schedule but let's just put every 24 hours yeah every 24 hours you can do explicit duration relative duration um that might be quite useful to do relative duration of um the record right now let's save it now what this is going to do now we'll put the wait timer in it's going to go approval is created and it's been requested every 24 hours so wait 24 hours then send the email go back around the loop okay so it's going to get to this bit go back around the loop okay wait 24 hours go back around the loop and that's going to happen until the approval record is approved [Music] now let's just expand on this a little bit more okay let's get a bit more fancy so let's say we've got this approval reminder in and the customer's really happy or at least you're um perhaps it department is really happy right but they kind of say well people are getting a bit spammed they get a bit annoyed we only want to send it three times so but the approvals on average take 10 days to approve so we don't want to send 10 emails one for every 24 hours we only want to send three so what we can do is at the top here we can in fact we'll create it here we go to flow variables sorry on the right hand side we create a flow variable now if we create um remind uh attempts and we give that an integer okay and up here we might need to get rid of that and up here the first thing we're going to do is we're going to set that flow variable okay so we're going to flow logic I'm doing lots of flow logic there it is do the following until we're going to set a flow variable that we've just created approval reminder attempts now we're going to set that to three now of course what you could do is you could use the script to go and pick that up from a property and put that in some kind of a property and give that out to I don't know catalog um admins perhaps if you wanted to so they could change their own however waffling three attempts so we've got the number three so we're declaring that outside of the do the following the do the following until logic inside once we've sent email what we want to do is is we're gonna change the number that that flow variable is so it started at three and here what we want to do is we're going to go set flow variables we're going to get approval reminder approval reminder sorry a reminder attempts we're going to pick flow variable so we're going to select so we're going to set the flow variable to itself minus one right so we're setting that flow variable reminder attempts to itself and then we're going to use this this function thing right so you if you hover if you like that you can't see it hover over it you're gonna be able to click it and then what you can quite simply do is click the math there's loads of different functionalities or utils that will kind of Transformations that we can play with right but we're going to pick subtract you could go add and do it the other way around I'm not going to one so we're going to subtract one okay and then we're done let's get rid of that so let's just look at what that's doing we declare the flow variable at the top of reminder attempts to number three we set it equal to number three in the loop the do do the following until Loop we're taking off one from that number each time it goes around the loop so the first time it's going to go to the second time it's going to go one the third time it's going to go down to zero because we're subtracting the number one from the flow variable hope that makes sense it's just going to keep going down so now what we can do is we can actually say stop the reminder when the state is approved or flow variable is zero we're going to keep going around the loop keep annoying people with an email um which there's better ways to send it go and check out another video um until it's been approved or we're gonna keep decreasing I can't think of the word then we're going to keep decreasing the variable that we set right at the start of the flow and until like when that hits zero then we're going to stop annoying people okay and then we can end this flow okay so I hope this is something you can sneak away in your servicenow tool belt to kind of pull out when you need it most and I hope you found it useful and if you have found it useful don't forget like subscribe and share it with your servicenow buddies until next time I've been Russ and this is service nerd

View original source

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