Category : NetSuite SDF
By leveraging the latest SuiteCloud Platform technologies, SuiteScript 2.1 and SDF with a strongly typed, object-oriented language like TypeScript, you can streamline building account customizations faster. Whether you’re a beginner starting from scratch or seeking to enhance your existing customizations, you will find this useful. The specific advantages of each technology will be explained, and you will learn how to set up an SDF project to fully capitalize on SuiteScript 2.1, TypeScript, and ECMAScript.
Each of these technologies offers significant benefits:
Before you dive in, ensure you have set up SDF correctly. We will use SDF to define your project and sync local files with your NetSuite account. If you already have your account and development environment set up, you can skip this step.
The following setup will enable your NetSuite account with the required roles and permissions, set up an Integrated Development Environment (IDE) based on Visual Studio Code, and install all necessary SDF CLI tools. Finally, you will have to link an account to your SuiteCloud Projects.
You can watch this three part video to get your account setup:
If you encounter any issues enabling features, consider seeking help from an administrator – additional details are provided below.
● Enabling SuiteCloud Development Framework in the Target NetSuite Account (Administrator Only)
● Assigning the Developer Role (Administrator Only)
● SuiteCloud Development Framework Account Preferences (SDF Developers Only)
● Setting Up a Role for SuiteCloud Development Framework Development
To get started, create a new SDF project using the SuiteCloud Extension for Visual Studio Code. This project will act as a container for all the customizations you’ll be working on.
To create a new project using the SuiteCloud Extension for VS Code, follow these steps:
Your new SuiteCloud project is now set up in the selected folder. You can start developing customizations by creating new SuiteScripts, Suitelets, or other NetSuite components inside the File Cabinet folder.
Here are some very useful SDF commands:
The SuiteCloud extension provides various commands accessible from the Command Palette (Ctrl + Shift + P). You can use these commands to deploy your project, create new script files, and more. Using these commands, you can effectively manage and develop your SuiteCloud projects within Visual Studio Code, making the development process more efficient and accessible.
Alternatively, you can right click on a folder or file and you’ll see these options. For more useful tips and examples, refer to this helpful reference: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/chapter_158400948906.html
By leveraging the VS Code SuiteCloud IDE Plug-In, you’ve seamlessly set up your account customization project with connectivity to NetSuite services. With most of the work already done, the final step involves installing TypeScript into your project. This integration ensures that your SuiteScript 2.1 customizations become more reliable and efficient, while maximizing the benefits of the SuiteCloud IDE Plug-In for a streamlined development experience.
First, create a package.json file in the root directory:
{
“name”: “SDF TypeScript Project”,
“version”: “1.0.0”,
“devDependencies”: {
“@hitc/netsuite-types”: “^2023.1.9”,
“typescript”: “^5.0.4”
}
}
Next, run npm install in the root directory.
Note: Typescript and netsuite-types packages are devDependencies, which you install on your local machine for tasks like formatting, testing, and building. These packages are not included in the production build of your application. The netsuite-types package provides TypeScript type definitions and declarations for the NetSuite SuiteScript API, allowing you to write type-safe code and benefit from code completion and type checking while working with NetSuite SuiteScript in your TypeScript projects.
Next, create a tsconfig.json file in the root directory:
{
“compilerOptions”: {
“module”: “amd”,
“target”: “ESNext”,
“sourceMap”: false,
“esModuleInterop”: true,
“experimentalDecorators”: true,
“noUnusedLocals”: false,
“moduleResolution”: “node”,
“newLine”: “LF”,
“baseUrl”: “.”,
“lib”: [“ESNext”, “dom”],
“paths”: {
“N”: [“node_modules/@hitc/netsuite-types/N”],
“N/*”: [“node_modules/@hitc/netsuite-types/N/*”]
},
“outDir”: “src/FileCabinet/SuiteScripts/”
},
“include”: [“src/TypeScripts/*”],
“exclude”: [“node_modules”]
}
Finally, create a folder under the src folder called TypeScripts where you will place the TypeScript files. Once you write your SuiteScript 2.1 code and save it in the TypeScript folder, running the tsc command in the terminal will invoke the TypeScript compiler. The compiler will look for the tsconfig.json file, transpile the TypeScript code into JavaScript, and save it to a file inside the SuiteScripts folder in FileCabinet.
Your project structure should look like this:
By taking full advantage of the capabilities available with SuiteScript 2.1, SDF, and TypeScript in your NetSuite customization projects, you can achieve faster iterations, develop higher-quality code, and build future-resilient applications. Unlock the complete spectrum of possibilities in SuiteCloud to create robust and flexible customizations that will elevate and grow your business on NetSuite.
Tags: