logo

NJP

Inside the Barrel - Batch Install ServiceNow Apps

Import · Oct 27, 2021 · video

welcome to inside the barrel where john and i are going to talk about cool things to do with servicenow and being a consultant in the space um we're lucky i'm lucky enough to be streaming from one of cask's office so maybe we'll even get a guest appearance walking by me um but yeah so today's episode we're gonna talk about batch installing um this one's near near and dear to my heart because there's so many times you're in a go live or you're about to do a new implementation and you have to install like 10 apps and you have to like sit there and wait to install every single one until the next one's done and then the next one's done then the next one's done and they've improved it enroll because now you can schedule those installs um so you can kind of schedule them back to back through the ui but today we're gonna go get into some code and show you how you can batch install multiple apps at the same time so awesome that sounds like fun yeah this one it shouldn't take us too long because it is a decently i've done it before so we could uh hopefully learn from some of that some of that work so if we're going to have john drive us all right let's see we're gonna have me try to navigate all of our shares you gotta okay oh good i i wasn't sure what i was sharing oh yeah well we're good this new way of doing stuff is different for me yeah all right all right so yeah let's kind of start with the documentation so where where do you start if you wanted to to batch install so there's uh servicenow has been building a rest api and even a flow designer spoke for you to essentially help you batch install and so um so this is the documentation that john has up about the the spoke and if we kind of just scroll down a little bit what's nice about this is let's see what all of the types of things you could do with it so you could do a batch install which is what we're going to show you can get the batch results so what's the progress let's say you wanted to roll back all the apps that you just installed so like something went wrong you can roll back what's also nice about the ci cd spoke you can do things like start atf's or instant scan so like imagine automating not only just installing let's say a custom scoped app or a stall app but you could install the thing make it run an atf and then like roll back if it didn't like if it broke something in your system so this kind of this kind of opens the door of some sort of like automated pipeline i'm using them using this spoke but let's dive into what that batch install one is so i think on a different tab you got yeah so this is the the the documentation that you'll probably want to to review before using batch install um to kind of walk through it but essentially allows you to install multiple applications um together so that you don't have to sit there and manually install and they kind of describe the two methods on the bottom is either using flow designer which is very easy to set up or using the the rest api so let's click on the rest api one just to kind of show people since we're going to be using a little bit of both we're going to be using the spoke but we're going to use some code to call it not flow designer so let's just kind of go down to um the the get call um so there's on the right hand side i'm just kind of looking at your um this headers is like you have the results call you and then you have a progress call to kind of see it and like let's click on one of those example curl messages just to kind of i guess any one of them really yeah and so essentially what it's doing in this case is you know trying to get the test results um but the idea is you know you send some sort of payload and servicenow is going to give you a response back so here's all the docs that you can kind of walk through we're going to simplify it a little bit for you since we'll have some example code and we'll put this on a github somewhere so that you could also utilize that that example code so the first thing we want to do is find out which apps to install so a good examples that come to mind are something like either customer service management because you have to install customer service maybe the action status maybe a portal etc so or in households and contributor user right there's a bunch of you know csm related applications grc is another example that comes to mind where you you want to install because they've broken them out into multiple apps so those are like the servicenow-based ones there's also you can install store apps so like tenable is a good one because normally you install the connector for tenable you install assets for tenable you install vr and itsm so what we'll use um we'll use tenable as our as our example here so if you scroll down to the bottom so the the four that we're gonna install are the tenable for assets tenable connector tenable for tsm and tenable for vr so imagine you were asked to go and implement these so if you click on one of them the thing that's important is that sys id up top in the url so it has like a yeah so for each all four of those i think i think john has an example of of those already recorded but just for um for your like if you were going to do this make sure you copy that cis id and then the version number so that that 4.0.1 so let's make sure that we have those saved so 4.1 on the what are we on that the asset one yeah yeah yeah i'm gonna i'm writing saving some code for you in the in the background did you want that sys id just um and that's for asset so for the asset one it should be it starts 9e and ends in 80. yep cool so we already got that so then so we got that version um let's collect the other versions so connector starts with a eight and ends with e4 connector yep and version is 4.0.1 oh so connector is also 4.0.1 cool all right turnable for itsm is 1-4 and ends with e8 uh so sorry you said ipsm is four dots it starts with one one four and ends with e8 one four and then e8 yep and then version is 4.0.0 yep all right and then the vulnerability response starts with cc ends with 8 d uh yes correct version is 4.0.1 awesome i just edited that for you on our little code snippet all right so now that we have those versions it's actually funny um i don't think tenable supports rome yet so we're gonna see how this is gonna work oh it's always the fun yeah oh hey another shot i don't remember the last time if we shout this out but man uh snu tills and their um fix for uh the background script where it now works much more like a ide oh thank you are nude that's awesome yeah that is a way better experience yes yeah all right so did you send me uh easy bake version of the dude yeah so the easy bake is in the oven the first thing we're gonna have to do though is create a credential for your account um so go to credentials and aliases hey you know i think i just did this for i was going through a uh um what did you say a credential and what and aliases yeah that one i think i just did this i was going through the ui builder thing and i think i had to create one for something so we're going to click new and we're going to select credential on the right-hand side of the type oh you know what i probably need to be different yeah probably gonna do there we go and then connection type uh yep oh sorry yeah perfect yep and then we could just name this like admin or you know you know it it's it's gonna be a credential admin of your instance that has access to install the um install the apps and what's nice is the api actually allows you to remotely install on another instance as long as the credential is there right so imagine you had a bunch of developer instances or subprods you could go and and from one like one instance go and call and install on all of them so you don't actually have to be on the instance to run the script um so so yep click submit and then for click on admin install credential and then click a new credential basic off or in our case and then name it admin and then for the username whatever i think it's i think it's admin unless you have a personal one and then do you know the password for your your instance uh no give me just a second though yeah i hit i hate it so you can let's see manage instance password all right now are we back we are back cool perfect um cool so click submit and so now let's copy the society of that connection and credential so not the one you just created yeah that guy let's copy that cis id beautiful and then in that code that i slacked you you're gonna replace that on like line six and then the code should be good did you see no more i edited that one so just said oh yeah okay all right all right like normal we have an awesome easy bake oven that i'll just get this stuff done faster so i'll paste it all in there um [Music] what line did you say to put it in this one um yeah that line yep that's so i zoomed in for for the audience um and let's kind of walk through this code so kind of the way we have this set up is in order to use the install batch api which is on on line 18 it requires a plan a batch plan an alias and a url so online six is our alias and i just wrote a little function that will go in and get the alias my lovely 12 through 16 is just a glide record but just very simple it requires the actual glide record so alias is going to be passed in on on line six so that's what that was for the instance url should be very easy because we can just get the instance url of the one we're working in but you could hard code that to be a you know https and whatever you want it to be and then the batch plan which we'll talk about where we're passing in some four different versions um and so those versions are above so that's what don was looking at earlier um and so let's scroll down to the install plan tenable apps and we'll come back to that function at the end so for install plan so what this needs to return is a json object um so that's that's what the install plan json takes in and so here essentially we're i'm just instantiating a bunch of blade blank jsons and then from there the meat of meat of this is for each of the apps that you want to install you need to essentially build on a an array of uh sorry build an object of of those parameters so in our case like the connector version that was the sys id of id what type of it is an application do you want to install demo data or not and then you know what version you want to install so that's pretty much the same for for all of them so um essentially you know if you keep scrolling down those are all look the same the other thing i did want to note is you could pass in notes and you could also install a customized version and what a customized version is is like let's say you have source control tied on tenable so that all of your customization are in your source control and also version differently you can install not only the tenable app as the base but also what customized version you have in your internal repository something something to keep in mind that's also a new feature of rome is essentially the idea of you could take any app whether it's a servicenow app or a store app and or um and use studio for it and maybe we should have a little video on that and tie it to source control so any of your customizations or configurations specific to your instance can be tied in source control and then versioned appropriately so you know we love series we like doing multiple episodes yeah so maybe that one next so yeah so this is this is an example of what it does we're essentially building a payload and then we return that payload once we have configured it all correctly and and going back to what you said about you you weren't sure that uh it was uh tenable was set up for rome um what i was just seeing you know how you said you know you're putting the version in there and it allows you to install different versions which over here you can find other app versions so you know in case you need to install a lower version number or a different version i believe that's how you would do it right you choose a you find what the other version numbers are yeah and then and then just switch it over there and that would install that version specifically and and exactly so good call out so i think we're so then what is the install batch so this function is actually directly taken from the uh code snippet in flow designer so if you ever go to any action um this one was the the install batch action and you load it and you click the the three little dots in flow designer and then copy code snippet this is this is an example of what it outputs so i didn't write any of this part of the code the only thing i wrote here is i return outputs and the reason for that is because i want to print that data um but if you wanted to run this and this is running synchronously if you wanted to run this asynchronously they even give you the code above it so you would essentially copy out the synchronous code and uncomment outline 27 but in order to get outputs it needs to run synchronously we need a response so that's why we're using that one so yeah very simple what this is going to return is a status if it is a 200 so did we have the right access um and then it's going to provide any error message and it's going to provide a progress url so we can even check the progress of how it's um how how it's going and you know what percent complete that it's going to be provides a rollback id in case we ever needed to roll it back so so i think we're ready to to test on roam whether or not animal quebec apps will work so i have my fingers crossed yeah here we go if we just get at 200 i'll be happy did that click i swear it did no oh you know what i probably actually need to call something don't i no there you go sweet look at that so we got some status so it installed a few things and hit some triggers and so if you scroll down to our script that i outputted so let's yeah sorry didn't uh do a better json string if i didn't get an error no error okay good percent complete a zero because it just started and it's pending um and then we have that progress url so let's copy that progress url and then open a new tab now let's do this real quick uh before i do that well i guess i could yeah that'll work hang on they've made me lazy about how you get into your new tabs because i usually just do it from the uh the other screen all right so so it failed that's okay i wasn't able to successfully install patch invalid or empty installation plan maybe it's because you clipped it twice oh maybe um that's okay so that's okay so on the left hand side we can see um progress of things so um if you type in batch install on the filter navigator you said batch yeah and under batch it should you have batch install upgrade history so you've installed other things batch installed that's cool um or at least servicenow is doing it but yeah so it should show up here um so it didn't um so something didn't go as planned so should i go back and then run it one more time or yeah that's a good question um yeah let's try running it again and see okay this time i will only click it once hands are up there we go then let's scroll to the right a little bit okay that is oh there we go i should have made our print a little bit better i'm sorry failed enable invalid or empty installation plan provided nothing to install all right so maybe something's wrong with their code so it's saying so it's it's not liking the installation plan which is that um so then all of those societies are right in those versions i wonder i wonder if it's because those versions don't exist on rome that we're not able to um to install it so let's let's um let's we'll try to simplify this let's go to the the the app store in like a tab a new uh not in uh yeah we could do from here or we could do it from the instance oh yeah let's type yeah plugins and we'll do this on the fly we'll install some customer service ones together so plugins well but it's not necessarily our fault yeah totally yeah we're too i forgot that's our problem i forgot you were on rome so it's like oh crap i don't know if it's gonna let us install it i don't i don't even know i'm trying to think i don't even think my other pdi is i think it's rome too because i i've had a a recent project of mine was trying to get an old portal up to snuff on rome that hadn't been upgraded well so during the the upgrades from whatever was in play in 2018 to now they've they've kept rolling back certain components to keep it working and so we had to come in and upgrade all that to get it working and so i needed rome to compare things with oh yeah yeah it was all right so let's um so we're going to install action status automation just just because oh so let's put this right here yeah well let's click on the we need to click on it yeah to get the society i'll give that a second this is super fast and i love that it tells me how super fast it is i know they don't like lazy load that or something so i think you can right click on this to get the sys id of this yeah so save that somewhere and then let's go back and get a another that is what is that what's this id because that's not what i got oh i'm not getting a cis id i'm getting com.sn underscore action underscore status interesting [Music] yeah this is what i'm getting right yeah that's what you get oh i should have been able get us a cis id i wonder if we could go to yeah see look at that uh oh you don't see it sorry i was looking at the x i was looking at the xml of it and it it does show that com. as an action status as the society that must be a really old thing that we stumbled on [Laughter] yeah um all right so we need to to get the society from that application is there a i'm trying to think of the easiest way to to get that on the fly so i think if we go to plug in like all available plug-ins on the left-hand side and not through this we should be able to to find it because there is like a different table type in like the uh like all available or something like that or like store yeah all available to obtain from store but does it run faster i think it no probably not because i'm stuck in this guy first yeah and then click that we'll just install like two store apps and all right let's type in customer service and is there any customer service one oh let's type in servicenow products because these are all the uh on the left-hand navigator go to servicenow products and let's see if we could find customer service should be on the bottom control fine customer service is it not on one of these is it's a product is it not maybe it's not alphabetical order wow all right so let's go to itsm oh my gosh i'm like in shock that it's not on here so all right let's go with the service now for microsoft teams we'll just install these four so let's see if we can get the like if you click on that well we get the sis id it's just going to open like a window to the store because up top it has a sys id in this url does it though right there on application yeah i don't have i don't necessarily have an actual look i don't see how i'm gonna get that from here we'll just take it from the uh we'll take it from the url all right yeah i'm gonna choose it'll be one four and something this is how i cheat oh yeah i i just know it that's so funny oh sure that's all that's all fine i think no this is good i like this better but this uh just yeah whatever i'm not i'm not getting but what i don't hate i i use this the other day and it's their copy paste out of here is annoying so hang on i gotta i gotta go paste it somewhere else now oh my gosh oh my god i can't win i know seriously that's so funny okay now i have yeah take the we need the app and the version so you save those two things uh let's see where were we they're over here the version of these two there's also in that url right we look at it let me see in this picture oh my gosh uh oh it is there yep i see very nice all right so let's go and get one more app so one more app on that list it can be in the service now for microsoft teams it's fine let's do notify connector and then take that url decode it and and then copy that version and id good to know that you can't install the api apps that aren't compatible with your instance well yeah it's probably i mean it's good to have that that uh stop there because that would really i mean that could seriously cause you some problems okay so we normally are we're trying to install four apps so just remove two of them essentially so just choose two like we only have to change the names of stuff but instead of those four choose just select two that you're going to use so version npr version and then you'll also need to to change uh and then change like yeah well so this is this is my thing that i i end up doing because i i i can't just delete stuff i have problems all good what if i have to come back and get it all right and then let's go that should be the same all everything else should be the same except our function we need to change a bit so we see one down here yes so really we we need to or i have to because i'm i'm bound by my own idiosyncrasies i can't break out of it and are we sure those are the two that we saved i'm just going crazy vr version see good thing i didn't delete it cool and so then just delete the you can leave those things because we're not like that's totally fine just delete this section of the code so we should only keep the asset one in the vr version so yeah i can delete connector asset one we keep and the vr1 okay now we don't have any changes there okay and so that's that's all we need now we just got to make sure the oh no no the asset version society so that's this id of the asset version or sorry of the the two dot whichever version needs to match on that one yeah so where it says ids we need to change i got this one all right now ready run that boom hands off run once there we go all right let's see what this one says hopefully watch it say the same thing hey so we should you said we should be able to um yes you'll be able to see that look at that type in batch over here and install and just give it a second to show up but it it will show up here okay and can we keep pounding on this guy to see yeah yeah oh there we go oh well no that one's the old one no that's the same one is it ec7 ec7 oh interesting invalid or empty install plan provided something is wrong with my code [Laughter] i don't understand well so this this one isn't i don't know are you getting like different feel like i ran this like yesterday but maybe i changed code since then it's saying that the install plan and we're returning the payload json stratified and we're saving that batch plan and then we're passing it interesting what is this one for oh you tried it this one should be the the first one we grabbed so number two don't know the right and it matches that society uh 2.0 14e it says application unavailable for installation on this instance so maybe we chose another one that we couldn't install on these well yeah but this is more information i feel like if i go back and actually click on install it'll work yeah yeah that's true um hmm wow i really like well um i think we're we're good on this one although we weren't successful um i think the gist of it is there i think so i think how hard how hard would it be to run through a flow one so the the flow one isn't like like we're getting the same result back right we're running through a flow right like you see the cis trigger and the flow context it's being created um we're essentially just mimicking what flow would do i think the i think the struggle is like trying to find an app after the our tenable one didn't work was was rough i totally forgot that we're not on on route um but yeah no i mean i think that's good though i think we'll we'll post that snippet so people can use i think the the hardest thing that i struggled with was creating that batch plan like what did that batch plan look like and um so so that will help people get to that point um and then making sure that we're able to install the actual the app on whatever instance it is so so maybe pro tip right now is make sure you're on quebec yeah or make sure you're like licensed for it because maybe we just took apps and oh yeah couldn't actually install on your on your dev instance um yeah you know and there and there that could be a lot of it too because because it's a pdi they may not be allowed so so let's actually show the the ones that you did have installed you did have the hr ones installed so let's go to that kind of to give people an idea yeah so let's click on the top one so this it looks like servicenow is actually i'm assuming you installed some hr thing here and i did install hr it was yeah because i was i was after some stuff on onboarding and transitions so yeah pretty much you know this is the same experience you would see right it would be the name of our so the install tenable apps right if it was here and then you just get a bunch of skip logs and changes applied um so just as if you were installing any app but this would have combined all of them into one and we could probably see this if you scroll to the right on changes applied and then in the upgrade details if we scroll to the right there should be different plugins um uh so let's go to the cog to add um and it should be um oh it is plug-in yeah so it's already move plug-in up a little bit yeah so normally you would only have one plug-in um per uh per install right and so this is showing that like it's installing based on a bunch of different plug-ins so so it probably runs its own batch because it's going to have multiple components of it yep and you know if i remember correctly when i installed this i i was you know it had a lot of requirements to get to have it so you have a lot of stuff that goes along with it anyways that you need yeah and my guess is servicenow's been using it for a while but i think they finally just like exposed it a couple years ago too because it's not even a friendly one right like it's not like you can select four apps and click install and like that would be handy if you could just go to the store and say you know add to batch add to batch and then yeah um and then schedule it right oh scheduling man how nice would that be if there was an ad to batch and then scheduling i think that would i mean that's what we're trying to solve right is you know create a scheduled job for this right and run it at a certain time and then here's the batch plan so like your go live is like it'll start running when you're when you're ready for it um but that's that's the dream to make it easier but so yeah we'll close this code um and you'll you'll be able to use it um just find the apps that work for you and it should be relatively easy and if you have any questions just you know kind of let us know and maybe we think about uh revisiting this one down the road um yeah yeah with other information you can come up with yeah the the tough part is like let's say you install batch install or something then you have to like go back and reboot your instance or reset your instance and then do it again for on stream right so it's oh is that like we could get it working and then show them the results um sure so sure yeah no this was fun i i actually enjoyed like i i don't do a lot of this because i i just use the the plug-ins to install because i'm usually after one or you know ones or twosies to do but yeah i can see how this you know really would be helpful especially for you know the the platform side where they need to get stuff installed and they don't want to because yeah you go through and you mark the plugins and you're like you're sitting there looking at your watch watching that thing go and you're like oh my gosh i probably shouldn't have selected install data demo data because that's going to take forever now i i think that also the also nice part is you don't have to you're not stuck in waiting so normally when you click the install it takes a red right and you're blocked from doing anything this runs in the background so like in theory you could still explore your instance will probably be a little slow but you can still you know navigate around yeah and and that that is really you know a big thing because yeah you start the install and you're like well okay i'm gonna go do something else now because i i'm stuck here but if you do it you're you know with this this script it is nice because then you can continue on with other work that you may need to get done and you know pro tip as a consultant you need you know you have so much work you got to get done you can't just get stopped by a process and be like well i'm out yeah cool all right well thanks everyone for tuning in um we'll do probably a different one on source control next since that and maybe we'll come back to the batch installing apps maybe we'll start we'll get that really ready right before and then do the source control after so we'll let it bake a little longer yeah yeah so cool all right well thanks again we'll see you guys

View original source

https://www.youtube.com/watch?v=Robw4Md8-Oo