Author: Clemen Canaria
Email: ccanaria [at] gmail [dot] com | clemen [at] canariawerx [dot] com
Organization: CanariaWerx
A comprehensive collection of VS Code snippets for NetSuite SuiteScript development, supporting both SuiteScript 1.0 and SuiteScript 2.1.
This extension provides code snippets for all major SuiteScript script types and common patterns, supporting both SuiteScript 1.0 and 2.1.
- RESTlet (
ss21-restlet) - Complete RESTlet with GET, POST, PUT, DELETE handlers - Suitelet (
ss21-suitelet) - Suitelet with GET and POST request handling - User Event (
ss21-userevent) - User Event Script with beforeLoad, beforeSubmit, afterSubmit - Map/Reduce (
ss21-mapreduce) - Map/Reduce script with all four phases - Scheduled Script (
ss21-scheduled) - Scheduled Script template - Client Script (
ss21-client) - Client Script with all event handlers - Portlet (
ss21-portlet) - Portlet Script template - Mass Update (
ss21-massupdate) - Mass Update Script template - Workflow Action (
ss21-workflowaction) - Workflow Action Script template - Bundle Installation (
ss21-bundleinstall) - Bundle Installation Script template - Module (
ss21-module) - Reusable module template
- Search (
ss21-search) - Create and execute a search - Record Load (
ss21-record-load) - Load a record - Record Create (
ss21-record-create) - Create a new record - HTTP Request (
ss21-http-request) - Make an HTTP request - Try-Catch (
ss21-try-catch) - Try-catch block with error handling - Console Log (
ss21-console-log) - Console log message - Console Error (
ss21-console-error) - Console error message
- RESTlet (
ss10-restlet) - RESTlet with GET, POST, PUT, DELETE handlers - Suitelet (
ss10-suitelet) - Suitelet with GET and POST handling - User Event - Before Load (
ss10-userevent-beforeload) - Before Load event handler - User Event - Before Submit (
ss10-userevent-beforesubmit) - Before Submit event handler - User Event - After Submit (
ss10-userevent-aftersubmit) - After Submit event handler - User Event - Full (
ss10-userevent) - Complete User Event with all handlers - Scheduled Script (
ss10-scheduled) - Scheduled Script template - Client Script (
ss10-client) - Client Script with all event handlers - Portlet (
ss10-portlet) - Portlet Script template - Mass Update (
ss10-massupdate) - Mass Update Script template - Workflow Action (
ss10-workflowaction) - Workflow Action Script template - Bundle Installation (
ss10-bundleinstall) - Bundle Installation Script template
- Search (
ss10-search) - Create and execute a search with pagination - Search - Simple (
ss10-search-simple) - Simple search without pagination - Record Load (
ss10-record-load) - Load a record - Record Create (
ss10-record-create) - Create a new record - Get Field Value (
ss10-getfield) - Get field value - Set Field Value (
ss10-setfield) - Set field value - Get Line Item Value (
ss10-getlineitem) - Get sublist line item value - Set Line Item Value (
ss10-setlineitem) - Set sublist line item value - HTTP Request (
ss10-http-request) - Make an HTTP request - Schedule Script (
ss10-schedule-script) - Schedule a script to run - Submit Field (
ss10-submit-field) - Submit a single field value - Lookup Field (
ss10-lookup-field) - Lookup field without loading record - Transform Record (
ss10-transform-record) - Transform one record to another - Log Execution (
ss10-log) - Log execution message - Try-Catch (
ss10-try-catch) - Try-catch block with error handling - Get Context (
ss10-get-context) - Get execution context - Get User (
ss10-get-user) - Get current user ID - Get Role (
ss10-get-role) - Get current role ID - Alert (
ss10-alert) - Show alert dialog (client-side) - Confirm (
ss10-confirm) - Show confirmation dialog (client-side)
- Open a JavaScript file in VS Code
- Start typing the snippet prefix:
- For SuiteScript 2.1:
ss21-(e.g.,ss21-restlet) - For SuiteScript 1.0:
ss10-(e.g.,ss10-restlet)
- For SuiteScript 2.1:
- Press
TaborEnterto insert the snippet - Use
Tabto navigate through placeholders
Type ss21-restlet and press Tab to insert:
/**
* @NApiVersion 2.1
* @NScriptType Restlet
* @author Your Name
*/
define([], () => {
/**
* GET request handler
* @param {Object} requestParams - Request parameters
* @returns {Object} Response object
*/
const get = (requestParams) => {
try {
return { success: true, data: {} };
} catch (e) {
return { success: false, error: e.message };
}
};
// ... more handlers
return { get, post, put, delete: doDelete };
});Type ss10-restlet and press Tab to insert:
/**
* RESTlet Name
* @author Your Name
*/
/**
* GET request handler
* @param {Object} datain - Request parameters
* @returns {Object} Response object
*/
function get(datain) {
try {
return { success: true, data: {} };
} catch (e) {
return { success: false, error: e.toString() };
}
}
// ... more handlers- ✅ Dual Version Support - Both SuiteScript 1.0 and 2.1
- ✅ Modern Syntax - ECMA 6 for SuiteScript 2.1 (arrow functions, const/let, destructuring)
- ✅ Legacy Support - Traditional function syntax for SuiteScript 1.0
- ✅ JSDoc Annotations - Better IntelliSense and code documentation
- ✅ Tab Stops - Quick navigation through placeholders
- ✅ Error Handling - Proper try-catch patterns included
- ✅ Attribution - @author tag for code ownership
- Visual Studio Code 1.80.0 or higher
- JavaScript language support
- Open VS Code
- Go to Extensions view (
Ctrl+Shift+XorCmd+Shift+Xon Mac) - Search for "SuiteScript 2.1 Code Snippets"
- Click Install
- Reload VS Code if prompted
- Download the
.vsixfile from the releases page - Open VS Code
- Go to Extensions view (
Ctrl+Shift+XorCmd+Shift+Xon Mac) - Click the "..." menu (three dots) at the top of the Extensions view
- Select Install from VSIX...
- Navigate to and select the downloaded
.vsixfile - Reload VS Code if prompted
- Clone this repository:
git clone https://github.com/ccanaria/suitescript-snippets.git cd suitescript-snippets - Copy the folder to your VS Code extensions directory:
- Windows:
%USERPROFILE%\.vscode\extensions\suitescript-snippets - macOS/Linux:
~/.vscode/extensions/suitescript-snippets
- Windows:
- Restart VS Code
- Open or create a JavaScript file (
.js) in VS Code - Type the snippet prefix (e.g.,
ss21-restlet) - Select the snippet from the IntelliSense dropdown that appears
- Press
TaborEnterto insert the snippet - Navigate through placeholder fields using
Tab - Fill in the placeholders with your specific values
If the snippet dropdown doesn't appear automatically:
- Press
Ctrl+Space(Windows/Linux) orCmd+Space(Mac) to manually trigger IntelliSense - Start typing the snippet prefix more completely
SuiteScript 2.1 - All snippets start with ss21-:
ss21-restlet,ss21-suitelet,ss21-userevent,ss21-mapreducess21-scheduled,ss21-client,ss21-portlet,ss21-massupdatess21-workflowaction,ss21-bundleinstall,ss21-moduless21-search,ss21-record-load,ss21-record-createss21-http-request,ss21-try-catchss21-console-log,ss21-console-error
SuiteScript 1.0 - All snippets start with ss10-:
ss10-restlet,ss10-suitelet,ss10-usereventss10-userevent-beforeload,ss10-userevent-beforesubmit,ss10-userevent-aftersubmitss10-scheduled,ss10-client,ss10-portlet,ss10-massupdatess10-workflowaction,ss10-bundleinstallss10-search,ss10-search-simple,ss10-record-load,ss10-record-createss10-getfield,ss10-setfield,ss10-getlineitem,ss10-setlineitemss10-http-request,ss10-schedule-script,ss10-submit-fieldss10-lookup-field,ss10-transform-record,ss10-log,ss10-try-catchss10-get-context,ss10-get-user,ss10-get-roless10-alert,ss10-confirm
- Enable Tab Completion: Ensure tab completion is enabled in VS Code settings
- Go to
File > Preferences > Settings(orCode > Preferences > Settingson Mac) - Search for "tab completion"
- Set
editor.tabCompletiontoonoronlySnippets
- Go to
- View All Snippets:
- Type
ss21-and pressCtrl+Spacefor SuiteScript 2.1 snippets - Type
ss10-and pressCtrl+Spacefor SuiteScript 1.0 snippets
- Type
- Customize Snippets: You can modify snippets in VS Code by going to
File > Preferences > Configure User Snippets > javascript.json - Use Multi-Cursor: Use
Alt+Click(Windows/Linux) orOption+Click(Mac) to edit multiple placeholders simultaneously
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under a Custom Source-Available License.
This means:
- ✅ You can fork this repository and modify it
- ✅ You can use it in your own projects (personal or commercial)
- ✅ You can use the code in your own work
- ❌ You cannot create standalone copies or redistributions
- ❌ You cannot republish this as your own work
⚠️ All forks must maintain attribution to the original author⚠️ Public forks must link back to the original repository
See the LICENSE file for full details.
Clemen Canaria - CanariaWerx
📧 ccanaria [at] gmail [dot] com | clemen [at] canariawerx [dot] com
Added complete SuiteScript 1.0 support with 30+ snippets for legacy script development.
Initial release with support for all major SuiteScript 2.1 script types and common patterns.