ANS-0856 · SUITESCRIPT DEVELOPMENT
Do NetSuite Library Scripts Require a Dedicated Script Record?
Learn how NetSuite handles shared JavaScript library files, distinguishing them from standard script records and deployments.
Short answer
NetSuite library scripts are JavaScript files uploaded to the File Cabinet. They do not require a dedicated NetSuite Script record or deployment. For SuiteScript 2.x, libraries are referenced programmatically as modules within the `define` statement of consuming scripts, enabling shared functions and efficient code reuse.
Scenario
A user is developing custom SuiteScript solutions and needs to understand the correct procedure for managing shared JavaScript library files. Specifically, they are unsure if a library script, after being uploaded to the NetSuite File Cabinet, also requires a separate NetSuite Script record to be created and managed via the script management interface.
Solution
To effectively manage custom SuiteScript, it is important to distinguish between three core concepts:
The JavaScript file: This is the actual code developed and uploaded to the NetSuite File Cabinet.
The NetSuite Script record: This is a record within NetSuite that references a specific JavaScript file from the File Cabinet.
The NetSuite Script Deployment record: This record enables the deployment of a NetSuite Script record created in step 2, specifying when and where the script should execute.For ongoing maintenance, once the NetSuite Script and Script Deployment records are established, only the JavaScript file in the File Cabinet (step 1) needs to be updated when changes are made to the script's code.A library script is fundamentally a JavaScript file (concept 1) designed to be used by other NetSuite scripts. It is not a NetSuite Script record (concept 2) itself and therefore does not require a dedicated script type (e.g., Suitelet, User Event, Client Script) or a separate NetSuite Script record.Instead of being managed through a dedicated script record, library files are uploaded to the File Cabinet. For SuiteScript 2.x, these library files are referenced programmatically as modules within the
definestatement of other NetSuite scripts that utilize their shared functions. This approach allows multiple script records to share common functions without each library file needing its own NetSuite Script record.Therefore, a library file needs to be uploaded to the File Cabinet but does not require a specific NetSuite Script record to be created viaCustomization > Scripting > Scripts. It is linked directly within the consuming script's code.
Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
