logo

NJP

Introduction to ServiceNow Script Debugger

Import · Jun 05, 2020 · video

Hey guys! In this video I'm going to talk about the script debugger of the ServiceNow platform. But before that I will go over all the prerequisites to understand this video better. The first one is obviously the knowledge of ServiceNow platform and the second one is scripting on the platform. But don't worry if you don't know what those are you can go to developer.servicenow.com to get started and come back to this video later. The third one is experience using IDEs such as VSCode, Eclipse or any of the others mentioned here. So what is script debugger? It's a feature that was developed to enable users debug the server-side code on the ServiceNow instance. Since it is JavaScript why can't we use dev tools of the browser to debug it? Well, server-side scripts by definition, run on the server side which are not accessible to the browsers. You can open the debugger in two ways. The first way is by typing script debugger in the left navigation pane of the instance or you can open it using the debugger icon provided above the script editor. We'll get to that in a minute.Do we need any roles to access it? Yes. You need to be an admin or someone with a script_debugger role. Alright let's dive into the demo. I already have a ServiceNow instance opened up here and I have created a table called inventory here. You can see that there are two columns. Item Name and Item Category and I've also created a business rule called onInventoryUpdate which will be triggered once we update any row of the inventory table. You can see that we have the 'update' checked for the table 'inventory' and this is a script which will be executed once any row in the inventory table is updated. So we can set breakpoints in the script by clicking on the gutter on the left hand side. Now you can see that the breakpoint has been set and we can open the script debugger by clicking on this icon. You can see that the breakpoint is updated here as well. Now let's go back to the original tab and perform some operation. Now let's update the Item Category of this row so that the business rule will be triggered once you update it. You see that we got a notification here to start the debugging. Once we click on it, it will take us to the debugger tab and you can see that line number four where we had put the breakpoint is highlighted. In addition to that, you can see other information such as Globals, Closures, Locals, Call Stack and Transaction Details. Don't worry about all this information right now. We'll get to that in later videos. Now you can see that the transaction is still paused here because we haven't resumed the execution of the script and here are the debugger actions for pausing, resuming, step in, step over that you find in other IDEs as well. So once we resume the execution the debugging is finished and the transaction is finished as well. so that's it for this video and we'll look into the conditional breakpoint in the next video. You can find more information about the script debugger in the links mentioned in the description. Please reach out to community.servicenow.com for any queries. Thank you

View original source

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