Step 2: Set Up the Dev Tools
Documentation article about Step 2: Set Up the Dev Tools
Step 2: Set Up the Dev Tools
Services handle HTTP requests sent by the frontend application to access backend models, which connect to NetSuite. Different releases of SuiteCommerce Advanced (SCA) handle services with significant differences. This section explains how to create a service when implementing the Vinson release of SCA or later.
-
2019.2 implementations and later provide two options: SuiteScript 2.0 or SuiteScript 1.0. How you go about this depends on the services you are creating. These implementations require Service Controllers.
Note:
The following code samples use SuiteScript 1.0 functions and objects only. These examples do not include SuiteScript 2.0 capabilities.
-
SCA implementations of Vinson through 2019.1 require only SuiteScript 1.0. These implementations require Service Controllers.
Note:
If you are using custom services that pre-date the Vinson release of SCA, you can still use them without refactoring your code. SCA offers backward compatibility with any services of implementations prior to Vinson. See Using Pre-Vinson Services with Vinson Release or Later for more information.
Much of the logic required to operate a service is contained in a centralized location within the source files provided. However, you must complete the following steps to create a custom service:
Step 1: Create a Custom [Module].ServiceController
Each service requires a unique [Module].ServiceController. You create this file, where [Module] is the module using the service. To create this custom ServiceController, complete the following tasks:
-
Define the custom [Module].ServiceController and dependencies
-
Add HTTP methods (as required for the service)
Create a new [Module].ServiceController file
-
Create a new file titled [Module].ServiceController.js, where [Module] is the module associated with the service.
-
Place this service controller file in the module's SuiteScript directory.
Define the custom [Module].ServiceController and dependencies
-
In your new [Module].ServiceController.js file, define the specific ServiceController and any dependencies.
-
Include ServiceController as a dependency. How you do this depends on your implementation.
The following code defines the Account Login ServiceController and enables the service to access methods defined in ServiceController and Account.Model.
1// Account.Login.ServiceController.js - Service to handle the login of a user into the system2"text-purple-400">define(3 'Account.Login.ServiceController'4, [5 'ServiceController'6 , 'Account.Model'7 ]8, "text-purple-400">function(9 ServiceController10 , AccountModel11 )Extend ServiceController
-
[Module].ServiceController must extend ServiceController and include the
nameproperty. This property is used when listening to an event. The value of the name property should match the name of [Module].ServiceController. -
Use the following example as a guide. The example shows this extension with the
nameproperty.javascript{'use strict';"text-purple-400">return ServiceController.extend({name:'Account.Login.ServiceController'
Add custom Validation Options (Optional)
-
If you need to define any validation options for the service, include these within
return ServiceController.extend. -
Use the following example as a guide. This example defines a requirement for the HTTP protocol to be secure before operating this service.
javascript, options: {common: {requireSecure: true}}
Add HTTP methods
-
Within the object returned, define the functions required to handle the HTTP methods for the service. This code reads the HTTP method sent from the frontend (POST, DELETE, GET or PUT).
For your [Module].ServiceController to function, you must declare each method in lowercase and it must match the name of the HTTP method being used.
-
Use the following example as a guide. This example defines what the service does on a POST request.
javascript, post: "text-purple-400">function(){"text-purple-400">return AccountModel.login("text-purple-400">this.data.email, "text-purple-400">this.data.password, "text-purple-400">this.data.redirect)}
Using these examples, your custom [Module].ServiceController might look something like this:
/Frequently Asked Questions (4)
Do I need to refactor existing code if it's pre-Vinson release?
What scripting options are available for 2019.2 implementations and later in SuiteCommerce Advanced?
What are the prerequisites to create a custom [Module].ServiceController in SuiteCommerce Advanced?
How can I secure a custom service in SuiteCommerce Advanced?
Was this article helpful?
More in General
- Field Service Management Enhancements and Bug Fixes for 2026
Overview of the 2026 Field Service Management SuiteApp updates showcasing enhancements and bug fixes.
- Example
Documentation article about Example
- Pass String Literals
Documentation article about Pass String Literals
- Manual Edits
Documentation article about Manual Edits
Advertising
Reach General Professionals
Put your product in front of NetSuite experts who work with General every day.
Sponsor This Category