logo

NJP

Script in Flow Designer, Like Ola!

Import · May 20, 2022 · video

[Music] [Applause] [Music] [Applause] [Music] [Applause] [Music] [Applause] [Music] [Applause] [Music] [Applause] hey everyone this is justin thanks for watching in this video it's a fast follow on my scripting and flow designer video or scripting like a boss and uh that same day that i recorded the video olan uh posted in the developer community exactly what i was talking about so he in his post he talks about getting questions of people doing date comparisons and wanted to do that in flow designer and there's some glide date time functions that i showed in my last video where i was actually putting that in um in action within service or within flow design so what he did is he created uh some comparison operations with actions and uh put them in an update set and you know put them out there for anybody to download so you can see here he's got uh difference in minutes difference in hours difference in days difference in weeks and the key concept here what i want you to take away is if you're doing stuff over and over again in scripting whether that's inflow designer or elsewhere go ahead and package that into something like an action where you can reuse it and repurpose it and you're not going and writing that same script all the time so what i'd like to do with you is i want to actually open this up and import it in my pdi with you watching so he put it over on share in the developer site so i'm going to go over there and uh do the download so you can see kind of the way um to do this safely let's uh you just never know what people are posting our line's been around for a while he's got definitely got a good reputation i'm going to open up this xml file in notepad plus plus and what i'm doing here um and what i'm showing you is that i'm downloading something but i'm just going to validate this is what it is so it's supposed to be an update set so let's confirm it was created by ola norlander and it's his date compare for flow designer that's the update set and we can see in here that this is an update set and that if we look down here it's basically a action type definition is what is in this payload so if we scroll through we can see uh he's doing some stuff in there he's got some a script here that's running through and doing his comparison and all the scroll way at the bottom there's a lot of stuff here in the payload and we can see that this xml file wraps with uh hey this is actually the end of his date compare for flow designer so everything looks good everything looks safe we're not importing any viruses or malicious code into our pdi that's just what i wanted to validate by opening up the xml so everything was good thank you for giving us safe code there and i'm gonna go ahead now to my pdi and navigate over to local update sets uh let's do update there we go and we're just gonna import this xml file that he gave us so uh we'll wait wait for it to load up here and what you can do in servicenow on the headers for any of your list views just right click and do an import xml and you could do this from any table i didn't have to go to local update sets and we'll just pull in that date comparison flow designer update set we'll upload it and then we should see that i'm just gonna search for a date here and actually it started with dates let me just search for date uh uh it's not showing uh you know this i always go to the wrong one let's go to the trees update sets and there we go [Music] and maybe it's showing there there it is okay date compared for flow designer so let's open that up we can see he created it and we'll go ahead and look it over it's got that sys hub action we saw on the xml file so i'm going to preview it and by previewing it it's just checking the file making sure it's good and there's no conflicts or issues so we see there in the blue or there was blue there's a no collision and there's only just one insertion so let's go ahead and commit that updates up and while that's committing i'm going to go ahead and pop open the flow designer so we can go in there and look at that we'll just check on how that did there okay it's 99 that's given the flow designer a chance to load up if you use flow designer you know it's not exactly uh really fast let's go ahead and start the flow here so we can see these and call them ola's date comparisons [Music] i love that people are able to share stuff like this for everybody to benefit from that really is the the one of the really nice things about the platform um this should have been committed by now nope still 99 only 400 lines come on okay that succeeded 100 and so that's just going to refresh that page and over in flow designer we're still waiting for that to come up okay so we got that i'm just going to set a trigger here to be a catalog item so not to mess with anything and then i'm going to look at my action here and we should have we'll just do date compare i think that's what was in his screenshot okay there we go i finally searched and okay there's our date compare that you put in there so we have a starting date time and ending date time that we can populate with that particular one and if we go look at um i'm going to go back home here in flow designer and look at the actions that came in and we'll just see the updated so we can see here he's got the date compare which came in on the today there's the ones i was doing in my previous video so let's open up his action and actually take a look at what he's doing so there's those inputs the starting date time and ending date time and then his script that does the comparison is right there so we can see it's quite a bit of code right so you're doing a lot there um doing the comparison and it can return the difference in minutes hours and days so there's a lot actually going on and then the output is going to output the difference in minutes difference in hours different than day so that's cool so it's actually not five separate actions like i thought it was in uh in this one right here where you can see the uh what's coming through it's actually going to return all of those values so i'm not going to just say hey i want a date comparison for the minutes hours and days it's just going to go ahead and calculate everything and return all of that with that function and you'll now have the difference in minutes difference in hours different stage differences and weeks so again i'll just emphasize here by looking at this script what ola did is instead of doing this over and over and over again inside of a flow and having to find the difference in the days hours or minutes he's com encapsulated it inside of an action that now can be dropped in any flow any subflow for someone who's not technical to actually use so all they have to do is either hard code in a date and time by using the date and time picker um they could drag and drop something from a data pill or they could now dot walk their way through a date time so we have the run start date time we have a requested item record that's associated with that so we could pull a date time for that and then just drop that in and then we're going to get back those inputs if you see above my head the difference in minutes hours days weeks months and years so i hope you found this video helpful and i hope you're starting to get the idea of how we can take scripting and enhance our flows and flow designer but then repurpose that and use them and let other people who are not developers not people who script use those uh actions in their workflows and their flows i hope you found this video helpful if you did please like please subscribe or share it with somebody you think might be interested until next time i'll see you on the next one [Music] you

View original source

https://www.youtube.com/watch?v=J_u7mUOH-cY