Errors with SuiteScript 2.1 Scripts

The following table summarizes when errors can occur with SuiteScript 2.1 scripts:

Scenario

Outcome

  1. Set the Execute SuiteScript 2.x Server Scripts As preference to 2.1.

  2. Open the script record of an executing script that uses an @NApiVersion value of 2.x.

  3. Edit the script and add code that is supported only in SuiteScript 2.1 (such as using the Spread operator).

  4. Save the updated script.

A syntax error occurs when you save the script. You can't save a script where you have added SuiteScript 2.1 syntax even if the Execute SuiteScript 2.x Server Scripts As preference is set to 2.1.

To resolve this issue, change the @NApiVersion value to 2.1 to explicitly run the script as a SuiteScript 2.1 script.

  1. Upload a script that includes an @NApiVersion value of 2.x and also includes SuiteScript 2.1 syntax (such as using the Spread operator).

  2. Change the value of the Execute SuiteScript 2.1 Server Scripts As preference to 2.0.

The script no longer works. When the account-level preference is set to SuiteScript 2.0, all 2.x scripts run as SuiteScript 2.0 scripts. SuiteScript 2.1 syntax is not valid in a SuiteScript 2.0 script.

To resolve this issue, do one of the following:

  • Change the @NApiVersion value to 2.1 to explicitly run the script as a SuiteScript 2.1 script.

  • Remove the SuiteScript 2.1 syntax from the script.

Related Topics

General Notices