SuiteScript 2.x JSDoc Validation

Note:

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.

Note:

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

                    /**
 * @NApiVersion 2.x
 */ 

                  
                    /*
 * @NApiVersion 2.x
 */ 

                  

The JSDoc tag comment block does not start with /**.

                    // @NApiVersion 2.x 

                  

The JSDoc tag comment is a single-line comment and not a block.

                    /**
 * @NApiVersion 2.x*/ 

                  

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:

For more information about entry point validation, including possible errors, see SuiteScript 2.x Entry Point Script Validation.

JSDoc Tag

Possible Values

Required/Optional

Description

@NApiVersion

2.0

2.1

2.x

2.X

Required for entry point scripts

Optional for custom modules

This tag is used in two ways:

  • For SuiteScript entry point scripts, this tag is a required declaration. It indicates to NetSuite the SuiteScript version to use.

  • For SuiteScript custom modules that are not entry point scripts, this tag is an optional declaration to specify the script version. This tag can be used to prevent compatibility issues if a script that references your custom module uses another SuiteScript version with language features or syntax that your custom module does not support.

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.

@NScriptType

BundleInstallationScript

ConsolidatedRateAdjustorPlugin

CustomGLPlugin

ClientScript

EmailCapturePlugin

MapReduceScript

MassUpdateScript

PaymentGatewayPlugin

PluginTypeImpl

Portlet

PromotionsPlugin

Restlet

ScheduledScript

ShippingPartnersPlugin

Suitelet

TaxCalculationPlugin

UserEventScript

WorkflowActionScript

Required for entry point scripts

This tag identifies the type of script defined in the file.

@NModuleScope

SameAccount

TargetAccount

Public

Optional

This tag is used to control access to scripts and custom modules.

  • If the value is set to SameAccount, access to the module is limited to other modules from the same bundle, as well as modules native to the same source account and any associated sandboxes and Release Preview accounts.

    Source code is not hidden at runtime.

  • If the value is set to TargetAccount, access to the module is limited to other modules from the same bundle, as well as modules native to the same source account, target account, and any associated sandboxes and Release Preview accounts.

    Source code is hidden at runtime.

  • If the value is set to Public, any script in the account can load and use the module.

    Source code is hidden at runtime.

The default value is SameAccount.

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 SameAccount.

For more information, see Controlling Access to Scripts and Custom Modules.

Related Topics

General Notices