Modern Programming Syntax and Behavior
SuiteScript 2.x is designed to be similar to JavaScript, so it's easier for JavaScript developers to pick up. The syntax is straightforward and the behavior is consistent. Some of the enhancements include:
-
Third party JavaScript API support: SuiteScript 2.x supports all standard JavaScript. The SuiteScript 2.x APIs let you access NetSuite features programmatically. For generic logic, you can use custom modules to load your favorite third-party JavaScript APIs.
-
SuiteScript 1.0 nlapi/nlobj prefix retirement: SuiteScript 2.x is designed to look and work like modern JavaScript, so its methods and objects don't use the nlapi or nlobj prefixes anymore. This change fits with the modular structure of SuiteScript 2.x. Methods and objects are now inside modules, whereas SuiteScript 1.0 kept everything in the nlapi and nlobj namespaces.
-
Usage of properties and enumerations: SuiteScript 2.x uses properties and enumerations. Most getter and setter methods from SuiteScript 1.0 are now properties, and enumerations are used for common constants like standard record types.
Note:JavaScript doesn't have a built-in enumeration type. In SuiteScript 2.x, an 'enumeration' (or enum) is a plain JavaScript object with a flat, map-like structure, where each key points to a read-only string value.
-
Updated sublist and column indexing: Most programming languages start indexing at 0, but SuiteScript 1.0 started sublist and column indexing at 1. SuiteScript 2.x now starts indexing at 0 to match modern JavaScript.
-
There's also a new version, SuiteScript 2.1, which is the latest minor version. It adds support for more ECMAScript features and syntax. For more info, see SuiteScript 2.1.
For additional information, see the following help topics: