SuiteScript 2.x Anatomy of a Script

All SuiteScript 2.x entry point scripts must conform to the same basic structure. The following diagram illustrates that structure. For an explanation of the numbered components of the script, refer to the table that follows the diagram.


For help with the terms defined in this topic, review SuiteScript 2.x Hello World.

SuiteScript 2.x Anatomy of a Script page

General Area



0 — JSDoc tags

2 and 3

The @NApiVersion tag, which is required in an entry point script, and its value. Valid values are 2.0, 2.x, and 2.X.

4 and 5

The @NScriptType tag, which is required in an entry point script, and its value. The value is not case sensitive, but using Pascal case, as shown in this example, provides better readability.

1 — define statement


The define function’s first argument, which is a list of dependencies, or a list of modules that the script loads. This script uses the N/record Module, which lets the script interact with records, and the N/ui/serverWidget Module, which lets the script interact with forms.


The define function’s second argument, which is a callback function.


The arguments of the callback function. The first argument is an object that represents the N/record Module. The second represents the N/ui/serverWidget Module. The sequence of these objects matches the sequence of the define function’s list of dependencies (Callout 6).

These objects can be used anywhere in the callback function to access the APIs of those modules. You can give these objects any names you prefer. As a best practice, use names that are similar to the module names.

9, 10, and 11

Entry point functions. For any function to be used, it must be named in the return statement alongside an entry point, as shown in Callout 17.

12, 13, and 14

The context object provided to each entry point function. The characteristics of these objects vary depending on the entry point. For an explanation of these objects, see Context Objects Passed to Standard and Custom Entry Points.


The callback function’s return statement.


The entry points used by the script. At least one entry point must be used. In an entry point script, any entry points used must belong to the script type identified by the @NScriptType tag (callouts 4 and 5).


References to the script’s entry point functions. For each entry point used, your script must identify an entry point function defined elsewhere in the script.

Related Topics

SuiteScript 2.x API Introduction
SuiteScript 2.x Hello World
SuiteScript 2.x Script Basics
SuiteScript 2.x Script Creation Process
SuiteScript 2.x Advantages
SuiteScript 2.x Terminology
SuiteScript 2.x Developer Resources
SuiteScript Reserved Words
SuiteScript Versioning Guidelines

General Notices