logo

NJP

Find the Code You're Looking For in ServiceNow | ServiceNow Tips & Tricks

Import · Sep 01, 2022 · video

foreign we'll talk about how to find that one piece of code that you're looking for and you just you just can't seem to find right we'll look in the metadata table and we'll look in the update set table and maybe in some tables that don't track to update sets like the scheduled script execution table and others stay tuned and we'll help you find that code the situation that I've set up here is that I have assigned some work to a developer to generate an event when an instant is deleted which will trigger an email will also trigger a script action right to do something asynchronously when that happens there's a scheduled job that does a daily check for these things just for fun and for the sake of the demo which also contains the name of the event so there's a handful of things that happen when this event gets triggered problem is it's not working and that developer has gone to PTO and I can't seem to track anybody down and I just have to go find the darn thing the only thing I know for sure is the name of the event so if I want to go find everything that the event touches I'm going to go to the metadata table shown here I'm going to highlight it for the sake of the video so you get some nice contrast and then enter now when this pulls up again I do know the name of the events what I'm going to do is do a keyword search for the event name and let's see what we find okay good I found four things these are four things I care about right I got my script action which is the asynchronous call that happens when the event is fired I got my scheduled script that for some reason triggers the event daily I don't know why we'd want to do that but it's a demo so why not right I got the actual event registration and I got a notification that triggers when the event is fired what I don't have is the actual business rule that fired the event so I'm going to go find that really quickly here and to do that I'm going to go to the update set table before I go there just a quick caveat on the application file table the metadata table this is traditionally going to be most everything that tracks to an update set right you might say to yourself Tanner scheduled scripts don't track the updates that's that's true however sometimes you will find them in the metadata Table and there are always in exceptions to the rule of not everything has to track to an update set to be here so that's a happy exception to that rule things that you're not going to find here normally would be things like workflow scripts or you know flow steps where you had a script get called and fired off an event I don't think you're going to find a lot of that here and that's going to be a little bit extra digging for you but most things are found here quite quickly and this is my go-to for finding things all right we didn't find my business rule though I know there is a business rule so let's go find the business rule my assumption is that someone deleted my event call from the business rule and I'm gonna go find out who so I'm going to the update XML table get that opened up when I come here what I like to do is compose a search where the payload contains the thing I'm looking for payload contains my event name in this case and I do have one there it is right it's in the default update set this is likely to be an earlier version of what's out there today I know it is because I deleted it from the business rule for this demo so I did find it though which is good now what I want to know next is obviously who deleted it and why and can we get it back right so let's go and open this back up go to Chevrolet record there's my event in this version which is good and oh look it was updated today at 8 44 in the update set fake fakey fake and that surely was what removed it we can obviously confirm that by doing a comparative current we've deviated slightly from searching but we do have to know if this is the version that had it and it is right so someone killed it in the fake fakey fake update set which is why it's no longer appearing in the metadata search for me so I've done my job of tracking this thing down I've done my job of finding out why it is no longer triggering and I even have someone that I can point my finger at when I say go fix this thing why did you delete that give me a good reason right that was my mission accomplished so from here we go actually fix the thing and then we continue with our lives living happily ever after foreign [Music]

View original source

https://www.youtube.com/watch?v=2AFHzSdzcFw