Debugging Deployed SuiteScript 2.1 Scheduled Scripts and Suitelets

You can debug SuiteScript 2.1 scheduled scripts and Suitelets that are in File Cabinet and have a Script Deployment record.

Note:

SuiteScript does not support read-only sublists. If you are debugging a script that loads a record with a custom child record as a sublist, make sure the Allow Child Record Editing setting is checked for the child record in SuiteBuilder. If this box is not checked, the sublist is read-only and will not load in the parent record. See Creating Custom Record Types for additional information about creating custom records.

To debug SuiteScript 2.1 scheduled scripts and Suitelets:

  1. Create your SuiteScript 2.1 scheduled script or Suitelet, upload it to the File Cabinet, and create a Script Deployment record for it.

  2. Go to Customization > Scripting > Script Debugger.

  3. Select 2.1 in the API Version field.

  4. Click Debug Existing Script. The Debug Existing popup window opens showing all deployed SuiteScript 2.1 scripts.

  5. Select your desired deployed script and click Select and Close.

  6. The Script Debugger page updates displaying “Waiting for User Action” message above the script. This means that it is waiting for you to perform the action associated with how the script is deployed. For example, if you script triggers on the beforeSubmit entry point of a user event script and is deployed on the sales order record, access a sales order and click Save.

  7. When you perform the necessary action, the “Waiting for devtools to attach” message is displayed above the script on the Script Debugger page and a new browser tab opens for Chrome DevTools.

    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.

  8. Your deployed script code is displayed on the new tab where you can debug as desired. A “Debugging <script>.js” message is displayed on the Script Debugger page indicating that the Chrome DevTools tab is ready for use.

  9. The Debugger will automatically stop at the first line of your script, which is normally the define or require statement. 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. See Tips for Debugging SuiteScript 2.1 Scripts for additional help when debugging scripts.

  10. When execution of your code is complete, “Completed Deployed 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
Debugging Deployed SuiteScript 2.1 Server Scripts
Debugging Deployed SuiteScript 2.1 User Event Scripts

General Notices