SuiteScript 2.x JSDoc Validation
If you are currently using SuiteScript 2.0 for your scripts, consider updating your scripts to use SuiteScript 2.1. This version includes new language features that are provided by the ECMAScript 2019 specification. For more information, see SuiteScript 2.1 and SuiteScript Versioning Guidelines.
JSDoc 3 is a documentation generator for JavaScript source code. Developers insert specific comment blocks into their source code, and these comment blocks can be extracted to generate documentation. These comment blocks start with /**
and end with */
.
JSDoc also includes its own markup language, which is made up of JSDoc tags. These tags are prefaced with the @
symbol. The JSDoc tags are added to the comment blocks, and they are used to specify the various entities of a JavaScript file (for example, @param
).
/**
* Creates a file
* @param {string} name - file name
* @param {string} fileType - file type
* @param {string} contents - file content
* @returns {Object} file.File
*/
JSDoc parses the source code for each comment block. JSDoc 3 also lets users create custom JSDoc tags. These tags can be defined to trigger events (for example, displaying a certain page).
SuiteScript 2.x includes several custom tags, such as @NApiVersion
and @NScriptType
. Some of these tags are required in each entry point script uploaded to NetSuite. To learn about these tags, see SuiteScript 2.x JSDoc Tags.
When a SuiteScript 2.x script record is requested, NetSuite uses JSDoc 3 to evaluate the entry point script and parse the code for the required JSDoc tag. This tag is used to validate the SuiteScript version.
SuiteScript 2.x users can use JSDoc 3 to create their own documentation for scripts, custom modules, and SuiteApps. To take advantage of this tool, developers must download JSDoc 3 from the official website. For additional information about JSDoc 3, see https://jsdoc.app/.
JSDoc Comment Blocks
To be recognized as valid JSDoc content, JSDoc tag comment blocks must start with /**
and end with */
. JSDoc tags consist of a key-value pair. The key is a string starting with @
, and the key ends with the first white space after this string. The value starts with the next non-whitespace character and ends with the next carriage return. Each comment line in the block starts with *
.
The following table lists examples of valid and invalid JSDoc formatting.
Valid Examples |
Invalid Examples |
---|---|
|
The JSDoc tag comment block does not start with |
The JSDoc tag comment is a single-line comment and not a block. |
|
The JSDoc tag comment block does not include a carriage return after the value. |
SuiteScript 2.x JSDoc Tags
The following table describes the available SuiteScript 2.x JSDoc tags. SuiteScript 2.x entry point scripts must include the following two tags:
-
@NApiVersion
-
@NScriptType
For more information about entry point validation, including possible errors, see SuiteScript 2.x Entry Point Script Validation.
JSDoc Tag |
Possible Values |
Required/ |
Description |
---|---|---|---|
|
|
Required for entry point scripts Optional for custom modules |
This tag is used in two ways:
The 2.x value usually represents the latest version of SuiteScript that is generally available and does not represent any versions that are released as beta features. However, this does not apply to SuiteScript 2.1. In this release, the 2.x value indicates that a script uses SuiteScript 2.0, not SuiteScript 2.1. You can still use SuiteScript 2.1 and all of its features in your scripts, but your 2.x scripts will not run as SuiteScript 2.1 scripts until a future release. For more information about SuiteScript versioning, see SuiteScript Versioning Guidelines. |
|
|
Required for entry point scripts |
This tag identifies the type of script defined in the file. |
|
|
Optional |
This tag is used to control access to scripts and custom modules.
The default value is
Note:
If your script contains SuiteScript 2.1 syntax that includes classes and will be included in a bundle, the @NModuleScope JSDoc tag must be set to For more information, see Controlling Access to Scripts and Custom Modules. |
Related Topics
- SuiteScript 2.x
- SuiteScript 2.x API Introduction
- SuiteScript 1.0 to SuiteScript 2.x API Map
- SuiteScript 2.x Script Types
- SuiteScript 2.x Global Objects
- SuiteScript 2.x Modules
- SuiteScript 2.x Record Actions and Macros
- SuiteScript 2.x Entry Point Script Creation and Deployment
- SuiteScript 2.x Custom Modules
- SuiteScript 2.x Scripting Records and Subrecords
- SuiteScript 2.x Custom Pages
- SuiteScript 2.1
- SuiteScript Versioning Guidelines