SuiteScript 2.x JSDoc Tags for JavaScript Documentation

SuiteScript 2.x JSDoc tags facilitate documenting JavaScript code, essential for effective script management in NetSuite.

·3 min read·View Oracle Docs

SuiteScript 2.x introduces JSDoc tags, enabling JavaScript developers to document their code effectively. This documentation is crucial for maintaining scripts and enhancing code readability, especially when working within the NetSuite environment. JSDoc 3, a documentation generator, provides a structured way to include detailed comments in the source code, facilitating the generation of comprehensive documentation.

What is JSDoc?

JSDoc is a documentation generator specifically designed for JavaScript. Developers can insert specific comment blocks into their code, which start with /** and end with */. These blocks can include various JSDoc tags, prefixed by the @ symbol, to describe different entities in a JavaScript file—most notably, parameters, return values, and a variety of script configurations.

Example of a JSDoc comment block in SuiteScript:

suitescript
1/**
2 * Creates a file
3 * @param {string} name - file name
4 * @param {string} fileType - file type
5 * @param {string} contents - file content
6 * @returns {Object} file.File
7 */

Using JSDoc helps to ensure that scripts are well-documented, making it easier for other developers to understand and maintain them.

Key JSDoc Tags in SuiteScript 2.x

SuiteScript 2.x utilizes several essential JSDoc tags, two of which are mandatory for entry point scripts:

JSDoc TagDescriptionRequired/Optional
@NApiVersionSpecifies the SuiteScript version to use: 2.0, 2.1, or 2.x. Required for entry points.Required for entry point scripts
@NScriptTypeIdentifies the type of script, for example, ClientScript, UserEventScript, etc.Required for entry point scripts
@NModuleScopeControls the scope of access for scripts and modules, with values like Public and SameAccount.Optional

Understanding @NApiVersion

The @NApiVersion tag serves as a declaration for your scripts:

  • For entry point scripts, it specifies which SuiteScript version to utilize.
  • For custom modules, it can prevent compatibility issues between different versions.

It is important to note that 2.x typically indicates the latest suite version available, but this does not apply to 2.1. In this instance, 2.x refers to SuiteScript 2.0.

Understanding @NScriptType

This tag delineates the type of script being created. Some common values include:

  • ClientScript
  • UserEventScript
  • ScheduledScript
    Understanding the script type is vital for the appropriate deployment and functioning of the script within the NetSuite environment.

Conclusion

With the integration of JSDoc tags in SuiteScript 2.x, developers can enhance their scripting process through better documentation. This not only promotes clarity in coding but also aids collaboration and maintenance in the long term.

Key Takeaways

  • SuiteScript 2.x uses JSDoc 3 for effective JavaScript documentation.
  • Key tags include @NApiVersion and @NScriptType, vital for entry point scripts.
  • Properly documented scripts improve maintainability and collaboration among developers.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

What is the purpose of JSDoc tags in SuiteScript 2.x?
JSDoc tags in SuiteScript 2.x are used to document JavaScript code, which is crucial for maintaining scripts and enhancing code readability in the NetSuite environment.
Are any JSDoc tags mandatory for SuiteScript 2.x entry point scripts?
Yes, the `@NApiVersion` and `@NScriptType` tags are required for entry point scripts in SuiteScript 2.x.
What does the `@NApiVersion` tag specify in SuiteScript 2.x?
The `@NApiVersion` tag specifies which SuiteScript version to use for entry point scripts, such as `2.0`, `2.1`, or `2.x`, and helps prevent compatibility issues.
Why is the `@NScriptType` tag important in SuiteScript 2.x?
The `@NScriptType` tag identifies the type of script being created, such as `ClientScript` or `UserEventScript`, which is essential for the script's deployment and operation in NetSuite.
Source: SuiteScript 2.x JSDoc Tags Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in SuiteScript

View all SuiteScript articles →