Our Blog


New Features and Functionality Enhancements in SuiteScript 2.0

inoday 1595 Views 0

SuiteScript 2.0 is designed to be modular. SuiteScript 2.0 implements its modular architecture with the Asynchronous Module Definition (AMD) specification. AMD is used to define and load JavaScript modules and their dependencies.

All SuiteScript 2.0 APIs are organized into modules. Each SuiteScript 2.0 module encapsulates a specific set of functionalities. For example, you load the file module when you need to work with files in NetSuite.

In SuiteScript 2.0, the define() function returns an object that encapsulates the module you are defining. Use the define() function to load SuiteScript 2.0 modules and create custom modules. When you use the define() function, it loads all dependencies before it executes any logic.

The require() function does not return a value. The require() function is used to load modules. When you use the require() function, dependencies are not loaded until they are needed. In the example below, the record module is loaded when record.create() is called.

Some of the highlights:

# All SuiteScript 2.0 methods take a plain JavaScript object as an input.

# All SuiteScript 2.0 booleans take a value of true or false. All other boolean values (for example: T or F) throw an error.

# Parameter types in SuiteScript 2.0 are strictly adhered to. You must pass in valid parameter types, as listed in the SuiteScript 2.0 help. SuiteScript 2.0 does not convert invalid parameter values to valid values.

# Enumerations encapsulate common constants (for example, standard record types).

# Sublist and column indexing begins at 0.

In SuiteScript 2.0, all client scripts support the use of Promises. With Promises, developers can write asynchronous code that is intuitive and efficient. SuiteScript 2.0 provides promise APIs for selected modules only. In addition, you can create custom Promises in all client scripts.

The API’s in SuiteScript 2.0 incorporate the latest JavaScript trends so it will be easier and faster because of SuiteScript 2.0’s intuitive experience. This will maintain full backward compatibility so all 1.0 scripts will continue to function.