SuiteScript 2.1, the latest enhancement to NetSuite’s scripting tool, represents a giant step towards NetSuite’s goal of conforming to the latest ECMAScript JavaScript specification. There are already significant benefits with the GraalJS (opens in new tab) runtime environment and how that gives SuiteScript developers access to the most current ECMAScript features and syntax out of the box. The SuiteScript 2.1, released in NetSuite 2020 Release 1, can help you do even more with NetSuite’s customization language.
As the ECMAScript specification continues to evolve at a rapid pace, it improves developer productivity, such as freedom from rewriting a lot of the same code over and over. The expressivity and power offered by the latest standards make it possible to write modern server-side code using arrow functions, block-scoped variables, spread operators and more.
Let’s take a closer look at just a few of these:
Spread Operator & Arrow Functions
Use the spread operator (“…”) to quickly combine two objects together into a single object as shown below. Couple that with the easy-to-use arrow functions to simplify function scope.
Destructuring Assignment
Quickly unpack properties from an object into distinct variables using destructuring assignment.
For a complete overview of all ECMAScript features, please refer to the 2019 Specification (opens in new tab).
There are a few more items that you’ll find useful. Currently, server-side scripts annotated as @NApiVersion 2.x execute as SuiteScript 2.0. As a part of this release, NetSuite has added an account-level preference giving you the flexibility to execute your server-side scripts annotated with @NApiVersion 2.x as SuiteScript 2.1. If for any reason you need to change the runtime behavior back to SuiteScript 2.0, it's as easy as flipping a switch.
These updates give you ample time to test all your server-side applications and libraries on the new engine powering SuiteScript 2.1 before rolling out to production. For more information on implementation timelines please visit the documentation page, (opens in new tab)and make sure you speak with your administrator as you plan for any changes.
Aligning SuiteScript with ECMAScript delivers enhanced developer productivity, more maintainable code and ensures ongoing conformance to an evolving standard, opening up a wide range of new possibilities for NetSuite customization. Here are a few resources to learn more: