Define, declare, and verify new variables and functions while you debug a script in
runtime using Console. The script execution must be paused in order to use Console.
Launch Script Debugger in one of the following ways:
Application
Navigation path
Application navigator
Navigate to System Diagnostics >
Script Debugger.
Studio
Navigate to File > Launch Script
Debugger.
Syntax Editor
Click the Script Debugger icon .
The Script Debugger modal is displayed.
Trigger the script.
For example, create a record to trigger an insert business rule script.
The Script Debugger pauses the script on the first line that contains a
breakpoint, and then you see the ServiceNow Script Debugger confirmation
window.
Click Start Debugging.
The focus shifts to the Script Debugger window and you see the target
script that paused at the first breakpoint.
Note:
Make sure that the status of
Script Debugger is EXECUTION_PAUSED. You can use Console only when the
script execution is paused during debugging.
Click the Open Console icon to expand the Console pane.
To start evaluating expressions, enter one or more expressions in the Console
and press Enter. For example, enter var x = 10; and press
Enter. To enter multiple lines of expressions, press Shift + Enter after each
line and press Enter after the last expression. To clear all the expressions in
the Console, click the clear console icon . For more information on Console controls, see Script Debugger step-through and console controls.
After a statement is executed, it is stored in the browser cache. You can use
the up arrow key to get the previous statement and down arrow key to get the
next statement from the browser cache. You can configure the number of cached
statements for a session from user preferences. For more information about user
preferences settings, see Script
Debugger and Session Log.