Evaluate expressions in runtime using Console

  • Release version: Washingtondc
  • Updated February 1, 2024
  • 1 minute to read
  • 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.

    Before you begin

    Procedure

    1. Launch Script Debugger in one of the following ways:
      ApplicationNavigation path

      Application navigator

      Navigate to System Diagnostics > Script Debugger.
      Studio Navigate to File > Launch Script Debugger.
      Syntax Editor Click the Script Debugger icon script debugger icon.
      The Script Debugger modal is displayed.
    2. 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.
      Start debugging confirmation window
    3. 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.
    4. Click the Open Console Expand 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 Clear console. For more information on Console controls, see Script Debugger step-through and console controls.
      Evaluating expressions in Console when a business rule execution is paused in the Script Debugger.
      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.