SuiteScript saw the release of a new version, made available as a beta feature, with NetSuite 2019.2. Minor changes and a few new features were added to the existing SuiteScript version 2.0 creating the new SuiteScript version 2.1. Listed below are details of some of the key changes and features that the developers can find with this new SuiteScript version.

(Read our post on Advantages of NetSuite SuiteScript 2.0 over SuiteScript 1.0.  You can also follow the link for more on the different SuiteScript types)

ECMAScript Support:

SuiteScript 2.1, is based on the ECMAScript 2018 (ES2018) edition of the ECMAScript specification. SuiteScript 2.1 and future versions of SuiteScript will also support features planned for future editions of the ECMAScript specification using ES.Next.

SuiteScript 2.0 is based on the ECMAScript 5.1 (ES5.1) edition of the specification, and it does not support the language capabilities included in ES2018 or future editions using ES.Next. 

SuiteScript Versioning:

The @NApiVersion JSDoc tag specifies which version of SuiteScript a script uses. As of 2019.2 release, there are three supported values for the @NApiVersion tag:

  • 2.0 
  • 2.1 
  • 2.x

To use SuiteScript 2.1, developers must explicitly specify @NApiVersion as 2.1 in the JSDoc tag as this is currently still in Beta. When Suitescript 2.1 becomes generally available in future, the 2.x value will indicate that a script uses SuiteScript 2.1

As long as 2.1 is still in Beta, the 2.x value will indicate that a script is using SuiteScript 2.0 which is the current latest version generally available.

Version Compatibility:

SuiteScript 2.1 is the latest version released as a beta feature in 2019.2. Developers can create and run SuiteScript 2.1 scripts alongside SuiteScript 1.0 and 2.0 scripts in their NetSuite account. Existing scripts are not affected. SuiteScript 2.1 is backward compatible with SuiteScript 2.0, which means that SuiteScript 2.0 scripts work as expected when they are run using SuiteScript 2.1 

Script Types:

SuiteScript 2.1 supports all standard script types such as User Event scripts, Schedule scripts, Suitelets etc same as SuiteScript 2.0

In their 2019.1 release, NetSuite has added a new script type called SDF Installation script, which works with both SuiteScript 2.0 and 2.1

Script Debugging:

As of 2019.2, developers have been unable to debug SuiteScript 2.1 scripts using the SuiteScript Debugger. For the time being logging can be used to debug these scripts. Support for debugging SuiteScript 2.1 scripts will be available in a future release of NetSuite. 

Developers can continue to debug SuiteScript 2.0 scripts using the SuiteScript Debugger.

Additional Features:

By using the newly added features in 2.1, developers can refactor their code and improve the performance.

In Suitescript 2.1, the let keyword allows you to declare a block-scoped variable to avoid certain problems related to variable hoisting in JavaScript. This is one of the latest ES2018 features.

Example:

for (let i = 0; i < j.length; i++)

{

let a = j[i];

...

}

It supports OOPS concepts like Encapsulation, Inheritance, Polymorphism, Interfaces. 

Suitescript 2.1 also has a feature called Arrow functions, which allows an implicit return when there is no body block, resulting in shorter and simpler code in some cases.

Example:

Without body block

hello = () => "Hello World!";

With body block

hello = (value) => {

   return "Hello World!" + value;

...

}

 

Note: SuiteScript 2.1 is still in Beta

 

Please follow and like us: