SuiteCommerce Advanced uses SuiteScript to access data stored in an NetSuite record. This enables SuiteCommerce Advances to access data that is not accessible from the Item Search API or the Commerce API.
SuiteCommerce Advanced uses SuiteScript in the following contexts:
Backend models: all backend models are combined into a file called ssp_libraries.js. This file is stored in the root directory of the SSP application.
Services: all services in SuiteCommerce Advanced are deployed to the
services directory within the SSP application.
Being installed within the SSP application enables backend models and services to access the SuiteScript API to access data stored in NetSuite records.
The Case application module, for example, uses SuiteScript to access information stored in a NetSuite case record. When creating a new case,
Case.Model uses the following code:
var case_record = nlapiCreateRecord('supportcase');
The string passed to the
nlapiCreateRecord method is the internal identifier for the case record in NetSuite. Calling
nlapiCreateRecord creates a new case record in NetSuite. It also returns a copy of the object. This object is stored in the
Storing a record as an object enables you to call additional methods on the object containing the case record. For example, the following code calls the
getField method that returns the value of the record field passed to the method.:
var category_field = case_record.getField('category');
In this example,
getField returns the value of the category field.
Other modules use the
nlapiLoadRecord method to assign a NetSuite record to a variable containing an object. You can then call methods like
getField on the object to retrieve the values of specific fields within the record.
In another context, a model may call the
nlapiDeleteRecord method to remove a record from NetSuite.