logo

NJP

5 ServiceNow Scripted Business Rules you should have in your arsenal in New York

Import · Oct 24, 2019 · video

my name's Jason Miller founder of Aspen now solutions and we're about to unlock the power of service now to start off by thanking all twenty-five hundred and thirty-two subscribers in over 80 countries globally if you believe in transferring knowledge to those who need it most please click Subscribe Durer's your data when I be transferred to anyone outside of Aspen now without your consent ok everyone well I'd like to start off today by congratulating John Donahoe on moving on to Nike I believe he's going to be the third CEO of Nike if research went correctly today I was like wow that that news was totally shocking so congrats and I hope your successor mr. McDermott does as good of a job as you do because I'll tell you what there are some some big shoes to fill their hair so we'll see how it goes but the product is fantastic and it sells itself in my opinion so today we're going to be discussing five business rules that you should have in your arsenal if you're going to be a developer out there there's basically five that I've put together that I use most often when I'm dealt certain user requirements so I'm just gonna go on down the lists so to start off you know creating a ticket when a configuration item goes down a lot of times we'll find that there's kind of like this manual process where if we mark a configuration item as not operational that will need to open up a ticket and the configuration manager is often tasked with with doing that or contacting the service desk so use this before to automate processes so basically the business rule kind of looks like this it's a it's an after business rule notice here it's after update so basically what we're saying is on the CMDB CI table there's an existing item which I'll show you in a second and if we were updating it and the operational change the status changes to not operational then here's what's gonna happen there are no I didn't put any field values in here I really wanted to get more into scripting and explaining how the scripting works here so what we're going to do is basically create a record on the incident table to get this Advanced tab to show up by the way if you first come into a business role might look like that so you're gonna have to click this advanced box right here so we'll go back into advanced create a variable called incident or I NC and then we'll see here new and then Clyde record and then we name the table here at incident and now you'll notice here initialize right so it's telling us hey we need to open up a record and then we're gonna fill it out with these values right here so we're gonna see here incident meaning from the incident table CMD CI CMD BCI excuse me we're going to use current dots this ID and then we're going to put in a short description here of just plain text configuration item down plus the name plus the asset tag and we'll notice here that we have spaces in between the pluses there we could even add a dash in there if we wanted to or whatever get creative with it then the description we're going to do the item plus the name of it at the following location location fine and then in the location will populate a new location that will insert the record into the incident table so let me just go ahead and demo this for you real quick we have here Superman and Robin they're already not operational so what I'm going to do is it looks like the asset tag here for this java application server that's the oh one so let's do that one not operation we're gonna go ahead and change it right here one thing I want to note is that I'm in a domain separating environment right now it looks like I'm in global but I've been telling going back and forth so we'll see when i refresh this incident list if only to show up that means I'll have to change my domain okay so great showed up so we'll see here okay looks like location came through the configuration item name is in the configuration item slot looks like there's no domain on the so it got thrown and said the default domain so maybe I'd want to define that and the either in the record or I could define it in the actual script itself right here we ever configure excuse me our short description so it says exactly we wanted to configuration item down java application server flx right it doesn't look like our other part of it mi a or the SDO one came through here so we could try that again with one of these other ones to see if it works here let's try changing this one operational and let's do down to operational for Superman and we'll see if this flows on through okay it looks like for here I've pulled it maybe it has something to do with being at the fault domain but I doubt it so I'll have to check the value in the table here and make sure this thing actually saved but it appears that it did so but we'll just move on so since one of them works great will declare victory on that then we'll go to number two push in fro from parent to a child so basically we have here a request a requested item and by the way all these are taken from real experiences that I've had trying to push values back and forth where they've you know customers have asked for certain values to be pushed down from the item to maybe like the approval here and we have here so this is would be what we call the parent record and then down here we would have the child record here now note with this option here is that you know you might want to be careful when you're scripting parent to child because remember you could have several children out there so if you don't want the value going to every one of the children you're probably gonna want to filter out your conditions here or inside the advanced script so this is a before and then we're just saying when you order car or excuse me order guide is Aspen now we're going to gonna run a query here so we're doing a variable of gr and we have a glide record here of sis approval underscore approval which is our approval table that we were just looking at there and then we're saying okay here's the field that we're looking at right and then we're going by a current that's this ID right so remember current is referring when we talk about current dot we're talking about right here at this table so just remember whenever you see current pop back up to the table okay so then we have our gr here which is what the approval table so we're saying you underscore order guide so the you underscore signifies what it's custom field and then current order guys so order guide it appears is just it's a regular out of the box field here so let's give it a shot we're going to put in an order guide of Aspen now on our rhythm right here and we're going to save it's hopefully the record doesn't disappear okay great and then we'll see here the order got changed to Aspen now so we essentially pushed the value from here to here kind of a nice you know feature that we can or something that we can leverage to push this down there and uh if if you ever have a requirement where you have to push values around a lot of times this sis approval table is a good place to go to look at you know different business rules and the way they construct them okay so oh yeah and this is just the list of the approvals there so got our number-3 create a new user record right so on the sister table from a task record so for this here let's say we have and I think the one I created was on the problem table so basically here's a problem record I'm going to refresh it because I've been in this screen for a while so I just don't want it to conk out later on okay great so basically what I set up here was a way for you probably like most of the time I when I've had these types of requests a great news user records it would be on the like off the incident because incident seems to be you know higher higher volume so and a higher probability that we'll need to create use new users off it but first today I wanted to use problem and if I click on this reporter by not found it comes up with all this additional information that will need to be created right so let's just take a look at the business rule though real quick and you'll probably recall one of my past videos I did one of these but with the variables coming off of the portal or excuse me a Service Catalog request off the portal so here's what we're gonna say here's reporter by is not found or changes the true write on insert or update I mean we could do insert so remember insert is when you first create the record and an update as anytime you update it but that's why we're putting in this changes to true because I'd have to actually toggle from one to the other and then we're gonna do an advanced here right so we have a very variable of new user and then new glide record right and then remember we had this construction before with the the configuration item right creating the incident so this is kind of the same thing right so we're saying here we're gonna initialize the record or bring it up and then we're going to do first name on the sis user record right we're setting the value off the on the sis user table of currents from a current right here on the table dot you underscore first name so these are all custom fields with the you underscore in front of them I'm not sure if all these camera if I defined all these in the actual script itself and then this last one here we're gonna see here I'm setting the flag back to false so I'm saying current you report have I not found equal to false so I want to change the flag back there right mainly because and that's another reason I put in this changes too because I want is the difference between is and changes too because if I did is and I kept saving it and if I didn't put this provision in here then I could create you know duplicate records right so what are we gonna do now we're gonna put in let's see here I don't know talked about John Donahoe before so I don't think he'll mind so let's see here we're gonna put in a domain let's put an aspen owl what the heck and then I think John's gonna be in Oregon now right but I don't know the or Ericka that something seems 3:05 alright and then we're gonna say John at Nike calm to be ok so it says congrats on creating an account for John Donahoe fantastic let's see if I can find him in here I might not be able to because of the domains but oh looks like he's here and then if I want to I'll click into the record and just make sure the a sure we'll save this why not let's go into the record click save and hopefully it won't take too long fantastic we have all the information that we wanted I don't know when my browser does this but it always populates it with user ID hopefully the people at ServiceNow watching us can you get that to stop or maybe that's just browser browser thing I don't know so we did the created look 19:57 I'm not sure if you can see my time up here but looks like it is correct alright fantastic okay so number four push info from a child to a parent well I put in here grandparent because this is gonna be one that the scenario work like this or the requirement was that we have users in a lower level domain so all of you out there who are in a domain separate environment and you have to mess around with this you know you only want certain people seeing certain domains but they might be a task FULFILLER but yet the requester like in the portal so the requester on the portal is making a request they're on a higher level domain it goes through the approval process it comes all the way down to the task levels or SC task level rights or a Catala but then the person at the the FULFILLER the very bottom level of the domain structure cannot see the actual task so what are they to do well they're they're gonna come crying to the support desk and say hey you know you need to give us access to those records so one way this was accomplished was by telling the system here okay go to request right and then notice right here is our query right Society current requests so remember current coming off of SC task so request is the field right and then we're querying by the Society and then we're saying okay we want this sis domain field meaning the domain field to be this on this record right we want to be the same as the currents on the assignment group does his domain so basically what was happening was we were putting in the record on the tasks level but they need to see the request they need to see what's going on there and sure I could I brought all those fields down I don't want them now but they still couldn't see them because the information actually is in another domain all right and also if you want to take a little bit one to run here just one more time this is after that was either insert or updated right any time it would changes that way it would change that assignment groups domain and that way it could be dynamic so that way you don't have to keep setting it for like if you have one item that's always fulfilled by a certain group but you never know in the future right the groups might change there might be a reorg something like that might happen so that ensures that it stays dynamic so if we take a look here here's a catalog task and I'm just gonna refresh this thing I want to reload this form it's probably gonna come up with a rule that I told my dumbass oh maybe okay yes okay so I've toggled my domain scope or expanded it and the reason I did that so that way I can change this I can I can be in one domain and then kind of see all the values are from other domain so here we have Aspen now and that's our assignment group and we'll take a look here I don't think we can see it this way I think I put the domain the list yeah okay so Aspen now here we have top right as our domain let's just click over here to our actual request remember keying in on the request and the reason why I put in the slide that is the grant you know the grandfather or grandparent it's because technically you know your request there's a one-to-many to the item and then to the catalog so I guess technically it's the grandparent but the request field is actually on the catalog has so it could be I don't know maybe a second parent I don't know so anyway here's our domain top right so it matches now let's try and change this thing to change it this Aspen dashboard group now we're gonna click Save now we're gonna go to our requests and I will see the domain has changed top FCT so anyone at the MCT level because let's say that like our original requester was in top but then our four fillers aren't MCT probably not gonna be able to see that information they're definitely not gonna be able to see that information so we need to bring it down to their level just for fulfillment and then you know we could create another business rule to flip it back up the top and this you know kind of alleviates the issue of having to go into all the codes you know the domain structure and change it all around and all that stuff so alright and then here is number five calculate real time story points okay so this one the requirement was scrum master basically the way this the stories work or sprints is that we'd have at the end of the Sprint we'd have like and I created some of these fields here that we'll get to in a second but basically if we take a look at our stories the main issue is that when we go into a story we don't have this like real time story points or anything we have like a total number of points I created let's see it was a percent complete I believe I create this real time story points and percent complained is already there I'm sorry but it's kind of binary it's either zero points towards the Sprint or you're a hundred percent done and all these points have already been have been counted right or have been accomplished but there's no way in the middle of it that like in the middle of this story if it's a bigger story and it's gonna take you like a week to do it but the you know scrum master is getting kind of worried because you're getting towards the end of Sprint they want to know what kind of percentage like real time your you are towards completing the goal of completing the story right so basically the issue was like they want a real-time number on the the amount of points or percentage complete and then secondary to that is they wanted it to roll up to the sprint so what we'll do now is and I'm just going to refresh this record real quick here okay so we come in here total story points so this is a tabulation that comes all the way up of all the stories so and one thing I did was and let's go actually let's go the business rule first sorry I don't want to get ahead of myself and I just did like state is not complete or excuse me it's not canceled and then we're going to insert or update and after the transactional runs on the arm story table I remember running this on the arm story table right but what we need to do is push it up to the sprint level so here's our query going off the number field then we're saying okay current parent that number and that's our query right there and then down here we're saying and this one you might want to kind of take a little bit of time to peel back so we're saying currents remember off the story right real time story points minus previous dot real time real time story points why did I do that in case the number goes down right so we don't want to double count the numbers and then down here we're saying gee are on the sprint table real time story points equals real time story points plus X okay so might take you a couple minutes to kind of digest that one but let's just watch it in action okay so here's our sprint we got 80 total story points well there's only one story down here right so let's just go ahead and change this to I don't know what are we gonna do here for this we're gonna say maybe 75 now let's just do 60 percent right there should be 48 points it's the real-time story points let's watch at the bottom here did it update yes and also I think I put a script on this like on sell edit so that way it actually automatically refreshes so that way the scrub master doesn't come back and say hey man you know like it didn't refresh and they don't have to automatically refresh with themselves so if I ramp down the points here and let's just make sure that unless it what's a percent complete 60 so I'm gonna do like 50 here I'll see if it takes both of these down so at this point didn't do the Auto refresh so what I'm going to do is I did ran the business rule here beautifully but it didn't on our line items so I think I have to put it in another on sell edit script for that but we'll see here a real-time story points is 30 so whenever I changed this like if I changed to 100 or I don't know just do 90 right so that's gonna be about 45 points it'll automatically refresh that will see right here our current story points completed so it would actually and then I have another business rule that you know if we had several stories in here it would tally up the points here at the sprint level I thought it was something kind of cool to do it definitely took me a couple of cycles to get a down pat with the refreshes and all that stuff and also thinking through like what if the number of points actually decreases and that's where we got that minus the previous in the actual script here so that was kind of critical to this because at one point there is double counting when I was in the testing of Ironman I said whoops all right got a kind of fix that real quick so just to review here are five ServiceNow business rules that we went over today if you learn something go ahead and click like or post the comments my name is Jason Miller found of a spinel solutions and we just unlocked the power of ServiceNow

View original source

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