logo

NJP

Zip and unzip attachments in #servicenow Flow Designer EASY MODE!

Import · Aug 08, 2022 · video

hey everyone welcome back to my channel my name is robert fedorick it is so good to have you here in this tokyo tour we are going to be looking at an excellent addition to flow designer called zip steps now a step is something that you can add to an action in flow designer and now what they're allowing you to do is use a flow action to zip or unzip or get details on the zip file of attachments to servicenow records super duper handy it's something we couldn't even dream of doing uh in the old workflow editor and now it is in flow designer as you all know i am a huge fan of flow designer if you haven't checked out my series go with the flow there'll be a little notification coming up in the top corner be on the lookout for that and please check out that playlist so now we can do cool stuff with zipping and unzipping attachments in service now it wasn't quite as obvious as i was hoping it to be so we are going to deep dive in this video and see exactly how it's done okay the docs for this feature says that there are three operations that we can now add to a flow action a zip operation an unzip operation and a get zip file details operation let's go check them out to demonstrate this i've created two incidents this incident 198. it has three attachments on it all screenshots then i have another incident incident 182 and it has a zip file let's go to our flow designer i've already got an action here waiting for us it's called experiment zipper action but it's got nothing done to it because we're going to deep dive the first thing i did was i put in an action input because we just want to use a incident to test with we have two test incidents so i have an action input of incident it's a reference incident and it's mandatory that way when we test the action we could just feed it an incident all right so the first thing we're going to do the first step is to look up records now first thing i want to say is this is the new step lookup interface way better i was so sick of having those gigantic icons teeny tiny text and having to scroll scroll scroll scroll scroll to get what i want this list is far more manageable and it's searchable so let's go look up and we're going to look up records now this took me a bit to figure out with zipping in a flow action it is not looking for the record that the attachments are attached to it is looking for the sys attachment records so we are going to look at the table of cis attachment that was counter-intuitive because we're thinking oh it's the incident it's the trigger right but we're going to look up sis attachments where the incident is the thing that holds the attachment so we're going to say table name is incident so the next thing we're going to do is that the table sis id this is the sis id of the record in the table that holds the attachment and that sys id is going to be the sys id of our triggering record so let's grab that and put that in there right now we're just looking at all the attachments for our trigger record in the sys attachment table now that we have that let's actually zip the records so we're going to add a step we're going to look up zip and it's operation there's three of them zip unzip and get file details we're just going to choose the zip now it wants to know the source for the attachment records and remember it's looking for a list of sys attachment records so we're going to go to activity one where we looked up the records i'm just gonna grab all the attachment records and put it there it doesn't matter if i have one doesn't matter if i have three doesn't matter if i have three million and it needs a zip file name so we are going to say this is the successful zip.zip you have all kinds of fun in there because this field is scriptable all right now it needs to know what is it going to attach the new zip file to how about the record that triggered this whole thing in the first place let's grab incident move to the target record it already knows the target table after that and we could do stuff like delete the source files we're not going to do that for right now we are going to do a couple other things now after i zip this file what i want to do is log the fact that i zip the file in the work notes and get see what kind of information i can get so what we're going to do is we are going to add another step zip and instead of zipping we are going to get the zip file details and it wants to know what zip attachment we made that attachment in step two so let's go to our zip step and let's take our zip attachment drop it in there and now it gets all kinds of details on that zip so now we are going to update the record which record are we going to update we are going to update the trigger record and we are going to add to the work notes that we're going to find out the number of files zipped and we're gonna do file information and this is gonna do some cool stuff we're gonna go to the to our zip step and grab number files and we're going to do the file details and once i execute this you're gonna see what that file details does because it could be zipping hundreds of files and what if i want information on any one of them so this is actually dropping an object so you can see what that output is let's save it and let's give it a test hit the test button we're going to put in our incident where we had the attachments let's run the test let's view the execution results okay no errors let's go back to that test incident and let's reload the form if we manage attachments we'll see that the zip has been successful this is the successful zip.zip and if we go to the work notes we will see it says that files zipped are three and it gives the file information in an array object so you can parse through that and get details on any one of those items if you so desire okay how about unzipping now i'm in my action for experiment unzipper action it still needs to look up a record now not plural singular you can't unzip plural records at a time yet that would involve you having to do a looping of some sort uh unzip requires a zip file to unzip so it's going to be look up records in this case it's the same deal it's just it's the table name of the task that's the trigger it's the sys id of the task that's the trigger and in this case we're looking for file name contains zip yes you can have a record multiple zip files on it you're just gonna have to figure that out in your own flow we're just doing an example here so it's gonna find the first zip and unzip it so the second thing i did was i looked up that zip step again we used the operation unzipped we used the source record that we just looked up that sis attachment record that was a zip file and we are going to attach everything from the zip into the task that triggered this workflow there are some advanced options here you can delete the source zip file once these things are extracted or you can give it special rules on whether it's unzipping all the files or selected files and if you pick selected files you're gonna have to deal with the most inappropriately named concept encoding regular expressions okay once we've unzipped we are going to update the record again we're going to add some work notes for the unzipped file and the number of files so we get that from here so number of files is going to be that and the file name that we unzipped is the attachment record okay let's save that and let's give it a test this is my record that has a zip file that we want to unzip let's run that view the execution details everything looked like it completed let's go back to the incident and refresh it now we see we have three files that came from that zip file and we see that we have some information the unzip file all those uh looks like a giant sys id and the number of files that was unzipped is three so this can be super handy for those integrations you use a flow designer where the destination is anticipating a zip file there's literally countless ways you can use this hope you learned some of this one and we'll see you on the next one if you're a servicenow expert looking for better opportunities but maybe your resume or linkedin profile isn't doing you justice reach out to me via linkedin or the email pictured here as i offer both career coaching and recruitment services and if you're a servicenow customer or partner you heard that right robert fedoric now does servicenow recruiting with a 1 500 subscriber youtube channel and mailing list and thousands of linkedin followers let's make sure your open positions get first go with the prodigious pool of servicenow resources reach out via the email picture here

View original source

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