Visual Studio Code is a favorite code editor of many developers (including us!). Understanding how to use SDF (SuiteCloud Developer Framework) in VS Code can significantly improve our effectiveness as SuiteScript developers. In the previous post, we covered how to install the SDF on your computer. Today, let’s cover the basics of how to use the CLI (Command Line Interface).
First, Some VS Code Tips
Opening Terminal
You can pull up the integrated VS Code terminal by typing CTRL + BACKTICK
(`) on your keyboard. You can also use your native teminal as well.
A Really Helpful Keyboard Shortcut
The most common command in the SDF Command Line Interface is “suitecloud file:upload -i
“. There is actually a way to make a shortcut for this command in VS Code. We sometimes use this shortcut dozens of times each day. So a shortcut can be really helpful!
To set up the shortcut, navigate to the VS Code “Keyboard Shortcuts” page. The quick way to get here is by using the keyboard shortcut, CMD + K + CMD + S
. You can also find this by navigating in the menu in the preferences area. Once there, you should see a small icon on the left side of the top right corner. Clicking this button will open up the JSON shortcut page for creating ultra-custom keyboard shortcuts.
Add a new shortcut with the following syntax:
{ // SuiteCloud Upload
"key": "cmd+u",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "suitecloud file:upload -i \u000D"
}
}
This will allow you to begin uploading from anywhere by simply typing CMD + U. Feel free to customize this shortcut or add additional ones!
The Basic Commands
In your terminal, type suitecloud
to get a list of all the different options we have to work with. And just so you know, you can always type CTRL + C
to exit the CLI from any point.
The most common commands that we will cover here are “suitecloud project:create -i
,” “suitecloud account:setup
,” “suitecloud file:upload -i
,” and “suitecloud object:import -i
.” The -i
means interactive. Sometimes you have to specify this if you would like to navigate in the interactive Command Line Interface list (which we nearly always want to). So just to be sure, it might be a good idea to always add -i
as you begin using the CLI. You can navigate through these CLI menus with the arrow keys, the space bar (to select a line when prompted), and the enter key.
The “suitecloud project:create -i
” Command
This command creates a SuiteScript project for you. It loads in all the necessary files for connecting with NetSuite. So when you decide to begin a project, navigate to the folder you would like to create the new project in. (You can navigate to a folder in your terminal by typing cd
and then dragging the folder from the left-hand file-browser into your terminal, then type enter.) The suitecloud project:create -i
command will prompt you to enter a name for the new project folder. This new folder will be created within the parent folder you are currently in. In the file-browser on the left, you will then see the project created with the folder name you specified, as well as some other folders and files. All your SuiteScript files should be put in the src > FileCabinet > SuiteScripts folder.
suitecloud account:setup
” Command
The “This command allows you to connect to a NetSuite account. You can select the “Create a new authentication ID (authID)
” option to connect to a new NetSuite account. Our favorite method is the browser-based authentication. Specify an authentication ID (we like using the company name + the type of account, like “suiterep-sb
” or “suiterep-prod
,” for example). Then, all you need to do is just be logged in to your destination account in your primary browser. The CLI will then open a new tab in the browser and connect to the currently logged-in account when you click “Allow.” Once clicked, your project folder will now be set to upload to that account. You can view which account is being used in the project by navigating to the “project.json” file in that project folder.
suitecloud file:upload -i
” Command
The “This command simply uploads files to your connected NetSuite account. Navigate through the menu to select which files you would like to upload. Remember, once uploaded, you will still need to create a Script Record and a Script Deployment Record in NetSuite to see the script in action.
suitecloud object:import -i
” Command
The “This command allows you to import objects into your project folder as XML files. These can be modified manually, duplicated, and/or uploaded to different NetSuite accounts. This is really powerful! I personally recommend saying “Yes” to the “all item types?” question and “Yes” again to enter an ID. You can then search for any of your objects in NetSuite (like custom fields, records, lists, etc.) by the internal ID.
Conclusion
This all may seem like a lot of information. After a few days of use however, these commands should become second nature and significantly improve your development efficiency. Try these out and see if the SuiteCloud CLI is something that might work for you or your team.
Do you find content like this helpful? Check out some related posts linked below and subscribe to our email list to stay up to date on our latest SuiteScript content!