Modular Architecture

SuiteScript 2.x is modular, meaning all its APIs are organized into standard modules. When your script loads a standard module, it can use any of that module's APIs.

Every SuiteScript 2.x entry point and custom module script needs to be set up to create a module. This doesn't apply to scripts meant only for on-demand debugging in the NetSuite Debugger or a browser console. For example, an entry point script has to create a module that the NetSuite application can use. In the same way, a custom module script also needs to create a module that other scripts can load and use. In both cases, the module should be set up to return an object, which is usually a function.

You create a module using the globally available define Object. You can use the define function to create and load modules in your script (see SuiteScript 2.x Hello World).

The define function can take one to three arguments, but most examples in this help center use two:

If you want to learn more about SuiteScript 2.x's modular architecture, check out the Asynchronous Module Definition (AMD) Specification, which SuiteScript 2.x uses. But you don't need to know AMD in depth to use SuiteScript 2.x.

Note:

Some samples in this help center use the require Function instead of the define function. Samples that use require are meant for on-demand debugging, either in the NetSuite Debugger or a browser console. If you want to use a script for anything other than on-demand debugging, it needs to use the define Object.

Related Topics

General Notices