On-Demand Debugging of SuiteScript 2.1 Scripts

On-demand debugging is for testing SuiteScript 2.1 scripts or code snippets that do not have a defined script deployment. On-demand debugging is not for scripts that have a Script record or defined deployment parameters (set on the Script Deployment page). See Debugging Deployed SuiteScript 2.1 Server Scripts for information about debugging deployed SuiteScript 2.1 scripts.

To debug SuiteScript 2.1 scripts on demand:

  1. Go to Customization > Scripting > Script Debugger.

  2. Select 2.1 in the API Version field.

  3. Enter you script code into the Debugger window. You may need to include a ‘debugger;’ statement for the script execution to pause in Chrome DevTools and allow you to gain control prior to script execution. Note that if you use @NApiVersion JSDoc tag in your script code, it is essentially ignored. Regardless of the value of the @NApiVersion JSDoc tag, your script code will be debugged as a 2.1 script.

  4. Click Debug Script. A new browser tab opens with the Chrome DevTools debugger and “Waiting for devtools to attach” is displayed on the Script Debugger page above the script. You might also notice that the font of the script in the Debugger window changes slightly, and that the legacy debugger buttons are grayed-out, with the exception of the red X button (that can be used to cancel debugging a 2.1 script). This is an added indication that the Chrome DevTools tab is being activated.

    Note:

    The first time you use the 2.1 Script Debugger, you may get notification that the popup window was blocked. To use the 2.1 Script Debugger, you must allow this popup window. To do this, click the button on the right side and select to always allow popup windows. You only need to do this one time. All future access to the 2.1 Script Debugger will be immediate.

    Note:

    When the Chrome DevTools tab opens, it may not show your code. Click the resume script execution button. On-Demand Debugging of SuiteScript 2.1 Scripts page to access your code. If you code is still not displayed in the Source window, click the :program line under the Call Stack section on the JavaScript debugging pane.

  5. You can now debug your code as desired. See Using Chrome DevTools for information about debug actions you can perform. Use the console to view all log messages. Your code may also be minified. Use the de-minify code button. On-Demand Debugging of SuiteScript 2.1 Scripts page) to display your code in a readable manner.

    See Tips for Debugging SuiteScript 2.1 Scripts for additional help when using the Debugger in on demand mode for SuiteScript 2.1 scripts.

  6. When execution of your code is complete, “Completed New Script Execution” is displayed on the Script Debugger page above the script. You can close the Chrome DevTools tab at any time after script execution is complete.

Note:

When script execution is complete or when an error occurs during script execution, you will see the message: Debugging connection was closed. Reason: Websocket disconnected. This is a normal message. You can close the browser tab and return to the Script Debugger where you can re-run your script or enter a new script for debugging.

Related Topics

SuiteScript Debugger
2.1 Script Debugger Overview
Introduction to Chrome DevTools for SuiteScript 2.1 Script Debugging
Debugging Deployed SuiteScript 2.1 Server Scripts
Tips for Debugging SuiteScript 2.1 Scripts

General Notices