Modular Architecture
SuiteScript 2.1 uses a modular architecture in which APIs are organized into standard modules. When your script loads a standard module, it can use that module's APIs.
SuiteScript 2.1 entry point and custom module scripts must be set up as modules. This does not apply to scripts used only for on-demand debugging in the NetSuite Debugger or a browser console. For example, an entry point script must create a module that the NetSuite application can use. Similarly, a custom module script must 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 by using the globally available define Object. You can use the define function to create and load modules in your script. For an example, see SuiteScript 2.1 Hello World.
The define function can take one to three arguments, but most examples in this help center use two:
-
The first argument is a list of dependencies, like standard SuiteScript 2.1 Modules. These modules load when the script runs.
-
The second argument is a callback function. This function needs a return statement that identifies at least one standard or custom entry point. The entry point should be linked to an object that's returned when it's called. Usually, that object is a function.
If you want to learn more about the modular architecture that SuiteScript 2.1 uses, see the Asynchronous Module Definition (AMD) Specification.
Some samples in this help center use the require Function instead of the define function. Use require for on-demand debugging in the NetSuite Debugger or a browser console. For scripts you use outside on-demand debugging, use the define Object.