SuiteScript 2.x Anatomy of a Custom Module Script
All SuiteScript 2.x custom module scripts have to follow the same basic structure. The diagram below shows that structure. For an explanation of the numbered components of the script, refer to the table that follows the diagram.

General Area |
Callout |
Description |
---|---|---|
0 — JSDoc tags and other annotations |
2 |
The title of the file that holds this script. It isn't required, but it can be useful. Any script that loads this module has to use this name. |
3 and 4 |
The |
|
5 and 6 |
The |
|
1 — define function |
7 |
The define function’s first argument, which is a list of modules required by the script. This script uses only one: the N/record Module, which lets the script interact with records. |
8 |
The define function’s second argument, which is a callback function. |
|
9 |
The arguments of the callback function. Because this script loads only one module, the callback function takes only one argument. This represents the N/record Module and you can use it anywhere in the function to access its APIs. You can name it whatever you want, but it’s best to pick something similar to the module name. |
|
10 |
The script’s entry point function. As you can see in the return statement (Callout 12), this function connects to the entry point named schedule. |
|
11 |
The context object that's available when the schedule entry point is called. Its property values are set by the script that calls this custom module. For an example, see SuiteScript 2.x Custom Module Tutorial. |
|
12 |
The callback function’s return statement. |
|
13 |
The custom module’s entry point: every custom module script needs at least one. Entry point scripts use a standard entry point from |
|
14 |
The function that’s returned when the schedule entry point is called. For each entry point, your custom module needs to return an object, usually a function. |
For details on the standard structure for an entry point script, see SuiteScript 2.x Anatomy of a Script.