netsuite-upload is a Visual Studio Code extension that allows you to manage your SuiteScript files directly from VS Code. It also helps you with defining new modules and adding server-side module dependecies.
In February 2019, original author original author Tomáš Tvrdý @tvrdytom transferred ownership of this project to me @silverl. The last version under this line of development was 0.1.3
.
New releases will be versioned 1.0+
.
If you are having problems with the 1.0+
release line, then make sure you've updated the vscodeExtensionRestlet.js
RESTlet to the latest version.
Right-click a file or folder in the navigation panel to see the context menu options:
Pull file from NetSuite
- downloads a file from NetSuitePush file to NetSuite
- uploads a file to NetSuiteDelete file in NetSuite
- deletes a file in NetSuiteCompare file with NetSuite
- diff your local version with the NetSuite versionPull folder from NetSuite
- Download the folder and all contents from NetSuite
Snippets for module initialization
- type defineRestlet..., choose your module type and hit enterCommands for adding new NetSuite/custom dependencies
- open command line (Ctrl
-Shift
-P
) and type- add netsuite dependency for choosing of the NetSuite built-in module from the list
- add custom dependency for defining od custom dependecies
You can set the remote destination folder in NetSuite to SuiteScripts (default) or a subfolder of SuiteScripts with the netSuiteUpload.rootDirectory
setting. This might be useful if you have a folder in the NS file cabinet called SuiteScripts\Development
where you experiment with scripts before you move them to a SuiteScripts\Production
folder.
In this kind of work flow, you might do development work within SuiteScripts\Development
. When you're satisfied, you'd change Settings.json (or Workspace settings in your .vscode\settings.json
file) to change the base to SuiteScripts\Production
. Then you'd push up all the files you were working with.
Nothing changes on your local disk due to this setting change. It only modifies the root folder in NetSuite where files get pushed to or pulled from.
This was a requested enhancement. Most people would probably be better off using a sandbox environment as it would be easy to lose track of which files were modified, and which versions of which files were in Development vs Production.
To be able to push and pull folders and files to NetSuite, this extension requires the manual installation of a RESTlet in NetSuite. Through configuration settings, you will inform the extension as to the URL of the RESTlet.
You'll need to know how to publish a script and do a script deployment in NetSuite to make it work. Consult the NetSuite docs if this is new to you.
- Download a copy of the RESTlet from here (use
Raw
view to copy/paste). - Upload the
vscodeExtensionRestlet.js
file to somewhere in yourSuiteScripts
file cabinet folder in NetSuite. - Create a new Script record for this RESTlet.
- Create a new Script Deployment for this Script. Note the URL.
- Edit your workspace or user settings in VS Code (see Settings section below) and set the RESTlet URL.
- Future versions of this VS Code Extension may require that you upgrade the RESTlet file in NetSuite. Take note if the extension receives an update, and read the Changelog.
- If you have an old version of the RESTlet in your Production NetSuite instance, and a new version in a SandBox NetSuite instance, be warned. A SandBox refresh might overwrite the SandBox RESTlet with the older version from Production.
The extension can be installed from the VS Code Extensions Marketplace within VS Code.
The Marketplace URL is https://marketplace.visualstudio.com/items?itemName=nsupload-org.netsuite-upload
Very Important Fact - Your VS Code project MUST MUST MUST be rooted at a folder that maps or corresponds to NetSuite's "SuiteScripts" file cabinet folder. This extension assumes the working root is equivalent to the remote "SuiteScripts" folder.
In VS Code, open the folder that corresponds to your local copy of the SuiteScripts folder in VSCode. That folder may not be named "SuiteScripts", but it should be the folder that corresponds to SuiteScripts in the NetSuite file cabiner.
You may manage settings for this extension either in your global user settings for all VS Code projects, or in a project-specific Workspace settings file that can be created or found beneath .vscode\settings.json
.
Keep reading for required settings relating to authentication and more.
This extension can authenticate to NetSuite and access the RESTlet script using either NLAuth authorization or OAuth 1.0 authorization.
Place the following in either Workspace settings or general User settings:
{
// Authentication header
"netSuiteUpload.authentication": "NLAuth nlauth_account=<ACCOUNTID>, nlauth_email=<LOGIN>, nlauth_signature=<PASSWORD>, nlauth_role=<ROLE>",
}
Where:
- ACCOUNTID is your NetSuite account ID number
- LOGIN is your email address used to log into NetSuite
- PASSWORD is your password (make sure you don't commit this file to source control)
- ROLE is the numeric NetSuite RoleID for which you have web service/API permissions. You may need to go look this up in NetSuite Setup…Users/Roles…Manage Roles.
Generating the necessary tokens for OAuth is covered in the NetSuite help site. It's not fun.
- If you wish to use OAuth authentication instead of basic authentication you can leave the authentication header blank and use the OAuth settings properties.
- First, generate an Integration record in NetSuite, make sure the 'token based authentication' scheme is checked, and hang on to the token and secret details.
- Second, log into a role you wish to use for authentication. From the "manage tokens center", generate a new token and secret using the Integration from the previous step.
- Input the 4 values from above (NetSuite key and token and Consumer key and token) in the corresponding settings options.
- Set the
realm
setting equal to your numeric NetSuite account number.
This extension requires the use of a NetSuite RESTlet. That RESTlet will be manipulating files and folders in the SuiteScripts folder of the File Cabinet. Therefore, the user being authenticated must have sufficient permissions assigned to their Role to allow these file changes, and to call the RESTlet script deployment.
At a minimum, the Role must have the following permissions:
- Lists…Documents and Files: Full
- Setup…Log in using Access Tokens: Full
- Setup…SuiteScript: Full
If you wish to upload and download into the SuiteBundles folder by changing the rootDirectory
setting, add the following permission to your Role.
- Setup…SuiteBundler: Full
The following demonstrates all possible settings.
{
// Script Deployment URL for the deployed vscodeExtensionRestlet.js
"netSuiteUpload.restlet": "<RESTlet URL>",
// Base NetSuite folder path to upload script to (e.g. "SuiteScripts/Developer"). Default if unset is "SuiteScripts".
"netSuiteUpload.rootDirectory": "<BASE FOLDER PATH>"
// Temporary folder (e.g. C:\\temp or /tmp) - used for diffing files between local and remote.
"netSuiteUpload.tempFolder": "<TEMP FOLDER PATH>"
// AUTHENTICATION - Use either NLAuth or Token Auth.
// Authentication header for NLAuth. remove or comment out if using OAuth.
"netSuiteUpload.authentication": "NLAuth nlauth_account=<ACCOUNTID>, nlauth_email=<LOGIN>, nlauth_signature=<PASSWORD>, nlauth_role=<ROLE>",
// If using OAuth, set all of these.
// Oauth NetSuite Key or Token ID
"netSuiteUpload.netSuiteKey": "<NETSUITE TOKEN KEY>",
// Oauth NetSuite Secret
"netSuiteUpload.netSuiteSecret": "<NETSUITE SECRET>",
// Oauth NetSuite Consumer Key
"netSuiteUpload.consumerToken": "<CONSUMER TOKEN>",
// Oauth NetSuite Consumer Secret
"netSuiteUpload.consumerSecret": "<CONSUMER SECRET>",
// Account number
"netSuiteUpload.realm": "<NETSUITE ACCOUNT NUMBER>",
}
You can add keybindings for a number of operations.
By default, two keybindings are pre-set in the Extension: upload and download.
- Upload: Ctrl+n,Ctrl+u
- Download: Ctrl+n,Ctrl+d
You can remap or set new like so in your keybindings.json
file:
{ "key": "ctrl+u", "command": "netsuite-upload.uploadFile"},
The plugin is using a RESTlet for the communication with NetSuite. RESTlets have some governance limitations, meaning NetSuite may throttle API calls if they are sent too rapidly. The current implementation does not deal with this, so there could be problems pulling folders containing a lot of items from NetSuite.