Variables, Call Stack and Closures in ServiceNow Script Debugger
hey guys in the previous video we discussed about the debugger actions you can find the link to that video in the description below in this video I am going to talk about the calls type transaction details and other variable sections that we have over here the first one is called stack this is something which is present in most IDs call stack keeps track of all the information regarding your program if you keep stepping into different scripts and at any point of time if you wish to know how you got there then call stack is the structure which helps you locate that information let's take a look at the demo we have three break points over here one in the scripting clue and two in the business rule if we go back to the inventory table and update a row it will trigger the breakpoint and you can see that in the call stack we have blind one and if you click it it's a UI action which triggered our business rule and the second one is the business rule itself where the execution is paused but it's at line number one and the third one is where our mission is currently paused line four and if you press step over it moves to line six and if we press step into it goes to script include and you can see that the call stack has changed now it has four entries and the latest one is lined one of the script include if you press step over again and then step into again you can see that the call stack has changed again but in this case it's line three and if you press resume it goes to line seven and the call stack also changes if you press resume again it goes to the next breakpoint which is a line 12 and the business rule and the call stack no longer contains a scripting clue because we are not in that script included anymore and if we press resume it finishes the execution the next section that we are going to look at is the transaction detail let's update the table and notice that whenever we perform any action the transaction details don't change because these are specific to a particular request you can see that the request parameters here and things which are specific to your instance the user and the page that you are currently debugging information like that so these are the things which would further help you if you want to know more about a particular transaction but as far as the script debugging is concerned these won't change let's look at the variables and closure sections now if we update the table breakpoint is triggered and you can see that there are local variables as well as global variables along with closures local variables are the ones specific to the script that we are debugging whereas global variables are specific to the entire system that is why you can see that there is GS glide system over here in the global but not in the locals and if you expand the locals you can see that it is the glide record related to the inventory table that you are trying to update and if we look at the previous one we can see that the item categories machines and the current one is machine which we are trying to update with and if we step over and then step into the scripting load you can see that the closure is no longer available because that is related to the business rule and if you step out again you can see that the closure is back because right now we are debugging the business rule and you can also see that there is a local variable I over here which is in the script and you can't find it in the global variables if you press resume script execution it goes to line 12 and then you can see that the eye value is 5 which is the last value after this for loop is executed so that's about the variable sections if you have any queries please reach out to community dot service no com
https://www.youtube.com/watch?v=8Q45xoYEPhI