ServiceNow Flow alternative to Scheduled Job | ServiceNow Flow designer live Use case | ServiceNow
[Music] hi all and welcome back so today we'll be looking on one more use case okay you must have encountered this use case in the past or in your organization so this use case is like if uh you want to trigger an approval email okay uh reminder emails okay to the approvals that they have not approved certain records this is pretty common use case i have seen in my organization also and whenever we look into this con this is a scheduled reminder okay the first thing which clicks in our mind is like scheduled job right whenever it's schedule schedule so we think okay schedule job is the right way to do that so whenever this kind of requirement comes so the first thing what you do you create an event after creation of you and you create a notification you uh make that particular notification on the to trigger on the basis of that particular event and then you simply go to the schedule job so you simply go to the scheduled job then yeah i will just try to create one schedule job with schedule job you click new and then you give it as automatically run a script okay so for example if you want to send a reminder notification to the approval approvals at eight o'clock in the morning okay or for example at one o'clock in the let's start it in the morning so eight eight o'clock in the morning okay so what do you generally do basically i will give it a name as a reminder notification reminder notification let me just make it properly reminder notification we make it a daily then we give it time okay i'm sending it on eight o'clock on a daily basis and then you write a script what kind of script you'll write so you know that approvals are getting stored in a table called says approval and that's called approver so i will just go dot list and this is where all the approval records are stored so we want to send the reminder revision on databases okay only to the users who have not approved or rejected the change the approvals okay so i will go with the requested show matching and that's it i want to uh i want to just send the notification to the user who i requested it and yeah that's it for now we can say okay so what i what do you generally do you just copy the query you can make it a table specific also for example you want to just send the rewind notification on the incident table so you can give the query like that so you can see what you generally do you do variable gr equal to new client record record then you will give here this underscore approve c is not underscore approved well underscore approval then you will go with like gr dot and encoded query okay whatever the recorded query will be so for us it's the state it was requested then you will be like gr dot query i'm just simplifying this script out okay because this is not the purpose of this video okay then you will be doing while gr dot next okay what we have to do we just trigger the gs.event queue okay so you'll be doing gs dot event queue not gi cheers dot event q okay if you want to see the videos on event q also i've already created videos so you can go and watch it and then we have certain attributes so it's like the first attribute is event name then glide record then pattern one paragraph and so on okay so this is how you generally do this killer job okay but what you might say you don't have to write any kind of code only you have a flow design you can use the flow design to trigger regular emails also okay reminder emails so how you can do that so basically what you can do you can simply i will just change the application i don't want to do it in this application i will go to the global application and what you can simply just generally do you can simply go to the flow designer and create a new flow so our use case like we just want to send a reminder notification so all the approvals so let's try to do the same what we were doing in the schedule via flow design i didn't waste a lot of time on the schedule because that's not the purpose of this video for me and it's taking a lot of time for me so let's wait for flow designer to get load i'm pretty fond of flow designer so let's try to get the things done with that so what we'll do we'll create a new flow okay we'll give it a name as the same remind turn not notifications okay always try to go with the no code approach okay or local approach okay rather than writing code wherever is possible you can give the description like send a notification to the true world okay that's it i will keep the application global protection run as well as initiative will give it system because your system generated notification right so the flow got created okay now is getting processed i don't want to take a tour okay we will add a trigger now in trigger we can give it a like daily weekly monthly you can see the date trigger right so we can have daily trigger we can have if you want to trigger the notification once a week then you can go for weekly in the similar way you can go monthly or in the repeated question so for now i will go with the daily one okay daily at what time so as we have again in the scheduled job we'll give it eight o'clock okay done so our trigger is ready now what do we do in the actions okay so first of all we'll get the records okay all the all the records which are in the requested trade for those this approval table so we will go and we will find for record query sorry you know what happened so we will go to the code okay or we can you can where is the code go to two okay and here we will first query the recorder to get all the notification all the records okay so we will do lookup records and look up records from which table so basically we will be looking up the record from the system rule table so i will just give approval underscore approval okay now we will set the maximum limit as thousand i don't care about that and we will give the condition so condition i will give see it is requested for now if you want if you want to give some additional condition you can give it to and also but i will i will i will just keep this condition for now okay order we don't have to give any other thing right and i will just go to the done okay now we got all the records okay which are all the approach which are in the request state now what should be the next step okay what action will now we want to send the notification to each and every for each and every uproar record right so what we'll do we'll do for loop because we want to iterate over the records right is it clear okay so we will go for sorry on a flow logic we'll go with the for each for each on what so we will go to the approval records for each one approval records that's it and then you can see as soon as you add the for each statement over there now we get let's see now we get an action over here right so for each record what action you have to do so we will simply go and type you will send a mail so how you can send a mail so there is an activity called send email in the similar way if you want to send messages also sms also you can have sent sms also so we'll go with the same email one and in the send email you can simply look at the action and send email target record target reload we will be like the records and we can we can take this approval record on the date so i will just fill this up with record come on it should come from 4-h approve record okay to what to so basically we have to we want to send it to the approval right it's approval approval so we will go to the data picker okay we'll go to voyage approve record and approval no approval dot email we have to do so approval record approval and from approval we have to find the email why i did a dot walk why did i didn't put uh take this as an input and this because the above will provide us this id and you can't send this ems to society right so we need a proper email that i took one more dot working with it so this and i will give it something this is the same and email okay and we can give please approve or reject the record the rules record okay you can you can add anything inside this okay um the content based on your requirements so you can have the data field over here also you can this and if i give what what i can give over here approval for and from accrual for we can give number okay so it will be like key whatever number record number you want to approve okay done so this is all you are done with the entire flow for the schedule okay whatever you are doing on the schedule so we can save it out okay if i go and if i see uh where is that approval record so in the requested there are 301 records okay and now if i touch this flow out let's see if it did if it does the same so i'm running the flow designer and it's processing so basically this is pretty easy right rather than writing a code so the testing got also finished okay and if you see what exactly it did so it's completed that's why it has sent the notification you can see it has iterated through 301 records okay and now you can see all the record bodies so you can you can hit it over here so for example here do we have the option to see the details let's see if if it gives so this is how we can we can um see you can see the html body so please upgrade the record approval record for this particular change request in the similar way you can just try it out through second record third record fourth record and you can see the two is getting changed based on the approvals and the target stack or suicide is also getting changed okay so in this way you can you can provide your own logic your own script your own email body your own recipients okay but you can simply use the flow design because it's pretty easy to use pretty easy pretty quick okay and this is a low code no i will not even cause it as low code i will call it as no good approach for the scheduled job okay so this was all for today's tutorial the agenda for this tutorial was like how to create a scheduled reminder how we can send a schedule reminder from the flow designer right so this is all for today's tutorial hope you like it out okay please like follow subscribe to my channel to get the latest updates on my upcoming videos and stay safe stay happy and have a nice day thank you you
https://www.youtube.com/watch?v=UmWEPz35DT4