Differences Between SuiteScript 1.0 and SuiteScript 2.1 Script Types
SuiteScript 2.1 supports the script types available in SuiteScript 1.0, but the two versions differ in script structure, entry point names, context objects, and APIs.
SuiteScript 2.1 also includes script types that have no SuiteScript 1.0 equivalent:
-
Map/Reduce scripts, which process large volumes of data in stages.
-
SDF installation scripts, which perform tasks when a SuiteApp is deployed with SuiteCloud Development Framework (SDF).
-
Custom Tool scripts, which expose NetSuite functionality to external AI clients through the NetSuite AI Connector Service.
In SuiteScript 1.0, the term event types is used to describe how a script was triggered. In SuiteScript 2.1, standard script types use entry points. An entry point is a function that runs when a corresponding event or action occurs. In many cases, SuiteScript 2.1 entry points correspond to SuiteScript 1.0 event types, but the entry point function receives a context object instead of individual arguments.
Custom Tool scripts are an exception. Their available operations and input parameters are defined by a JSON-RPC schema rather than by a fixed set of standard entry points.
For more information about SuiteScript 2.1 entry points, see SuiteScript 2.x Entry Point Script Creation and Deployment.
See the following help topics for specific information about the differences in each script type:
For more information about specific SuiteScript 2.1 script types, see the following help topics:
Bundle Installation Script Type Differences
SuiteScript 2.1 bundle installation scripts use the beforeInstall, afterInstall, beforeUpdate, afterUpdate, and beforeUninstall entry points. These entry points replace the SuiteScript 1.0 bundle installation event functions.
The entry point context provides bundle-version information. The toversion parameter is available for installation and update entry points, and the fromversion parameter is available for update entry points. Review the applicable entry point API when converting scripts that rely on bundle-version values.
For more information about the bundle installation script type in SuiteScript 2.1, see SuiteScript 2.1 Bundle Installation Script Type.
SuiteBundler is still supported, but it will not be updated with any new features.
To take advantage of new features for packaging and distributing customizations, you can use the Copy to Account and SuiteCloud Development (SDF) features instead of SuiteBundler.
Copy to Account is an administrator tool that you can use to copy custom objects between your accounts. The tool can copy one custom object at a time, including dependencies and data. For more information, see Copy to Account.
SuiteCloud Development Framework is a development framework that you can use to create SuiteApps from an integrated development environment (IDE) on your local computer. For more information, see SuiteCloud Development Framework.
Client Script Type Differences
Here's how client scripts differ between SuiteScript 1.0 and 2.1:
-
In SuiteScript 2.1, a client script includes the parameter:
currentRecord. -
In SuiteScript 2.1, the
fieldChangedentry point includes the parameter:column. -
The
typeparameter in the SuiteScript 1.0pageInitevent type is calledmodein the SuiteScript 2.1pageInitentry point. -
The
recalcevent type in SuiteScript 1.0 is thesublistChangedentry point in SuiteScript 2.1. -
In SuiteScript 2.1, the
validateDeleteentry point includes the parameter:lineCount. -
In SuiteScript 2.1, the
validateFieldentry point includes the parameter:column. -
SuiteScript 2.1 also includes the
localizationContextEnterandlocalizationContextExitentry points.
SuiteScript 2.1 client scripts execute in the browser. Use language features that are supported by the browsers used in your account.
For more information about the client script type in SuiteScript 2.1, see SuiteScript 2.1 Client Script Type.
Custom Tool Script Type Differences
Custom Tool scripts have no SuiteScript 1.0 equivalent. They let external AI clients invoke NetSuite functionality through the NetSuite AI Connector Service.
Custom Tool scripts are deployed through SDF and use a JSON-RPC schema to define tool names, descriptions, and input parameters. The schema determines the operations available to an AI client.
For more information, see SuiteScript 2.1 Custom Tool Script Type.
Map/Reduce Script Type Differences
Map/Reduce scripts have no SuiteScript 1.0 equivalent. They are designed for processing large amounts of data that can be divided into small, independent parts.
A Map/Reduce script can include the following entry points:
-
getInputData -
map -
reduce -
summarize
Use Map/Reduce scripts instead of scheduled scripts when processing large datasets that can benefit from parallel processing and staged execution.
For more information about the map/reduce script type in SuiteScript 2.1, see SuiteScript 2.1 Map/Reduce Script Type.
Mass Update Script Type Differences
Here's how mass update scripts differ between SuiteScript 1.0 and 2.1:
-
In SuiteScript 2.1, a mass update script includes the
eachentry point. There is no equivalent event type in SuiteScript 1.0. -
The
rec_typeandrec_idparameters used in SuiteScript 1.0 mass update scripts are replaced withparams.idandparams.typeparameters for theeachentry point in SuiteScript 2.1.
For more information about the mass update script type in SuiteScript 2.1, see SuiteScript 2.1 Mass Update Script Type.
Portlet Script Type Differences
Here's how portlet scripts differ between SuiteScript 1.0 and 2.1:
-
In SuiteScript 2.1, you can use a portlet for a SuiteApp.
-
In SuiteScript 2.1, a portlet script includes the
renderentry point. There is no equivalent event type in SuiteScript 1.0. -
The following methods are included in a SuiteScript 1.0
nlobjPortletobject, but are not included in the SuiteScript 2.1Portletobject:setRefreshInterval(n),setScript(scriptId). -
The following functions included in a SuiteScript 1.0
nlobjPortletobject are now properties in a SuiteScript 2.1Portletobject:-
The
setHtml(html)function in SuiteScript 1.0 is thePortlet.htmlproperty in SuiteScript 2.1.
-
The
setTitle(title)function in SuiteScript 1.0 is thePortlet.titleproperty in SuiteScript 2.1.
-
-
The parameters for the
nlPortletObject.addcolumnmethod have different names in thePortlet.addColumnmethod in SuiteScript 2.1:-
The
nameparameter in SuiteScript 1.0 is theidparameter in SuiteScript 2.1.
-
The
justparameter in SuiteScript 1.0 is thealignparameter in SuiteScript 2.1.
-
-
The
Portlet.addEditColumnmethod in SuiteScript 2.1 has the parameters:link,linkParam, andlinkParamName. -
The
nameparameter for the SuiteScript 1.0nlPortletObject.addFieldmethod isidin the SuiteScript 2.1Portlet.addFieldmethod. -
The
indentparameter for the SuiteScript 1.0nlPortletObject.addLinemethod is now calledalignin the SuiteScript 2.1Portlet.addFieldmethod. -
SuiteScript 2.1 portlet scripts include the properties:
Portlet.clientScriptFileIdandPortlet.clientScriptModulePath.
For more information about the portlet script type in SuiteScript 2.1, see SuiteScript 2.1 Portlet Script Type.
RESTlet Script Type Differences
SuiteScript 2.1 RESTlets use the delete, get, post, and put entry points. These entry points are equivalent to the delete, get, put, and post functions (http methods) in SuiteScript 1.0.
A RESTlet must expose an entry point that matches the HTTP method used to call it. Depending on the method, input can be provided in the URL or request body. RESTlet calls require authentication.
For more information about error handling with RESTlet scripts, see SuiteScript 2.1 RESTlet Error Handling.
For more information about the client script type in SuiteScript 2.1, see the help topic SuiteScript 2.1 RESTlet Script Type.
Scheduled Script Type Differences
Here's how scheduled scripts differ between SuiteScript 1.0 and 2.1:
-
In SuiteScript 2.1, a scheduled script uses the
executeentry point. There is no equivalent event type in SuiteScript 1.0. -
The SuiteScript 1.0
nlapiScheduleScriptfunction is replaced with the SuiteScript 2.1task.create(options)andtask.ScheduledScriptTask. -
The
typeparameter in the SuiteScript 1.0nlapiScheduledScriptmethod is replaced with thecontext.InvocationTypeenum in SuiteScript 2.1. The values are similar:SCHEDULED,ON_DEMAND,USER_INTERFACE,ABORTED, andSKIPPED. -
The
nlapiSetRecoverPointfunction in SuiteScript 1.0 has no SuiteScript 2.1 equivalent. The functionality provided by this function is not needed because of the way scheduled scripts execute in SuiteScript 2.1. -
The
nlapiYieldScriptfunction in SuiteScript 1.0 has no SuiteScript 2.1 equivalent. The functionality provided by this function is not needed because of the way scheduled scripts execute in SuiteScript 2.1.
For more information about the scheduled script type in SuiteScript 2.1, see SuiteScript 2.1 Scheduled Script Type.
SDF Installation Script Type Differences
SDF installation scripts have no SuiteScript 1.0 equivalent. The SDF installation script type performs setup, configuration, validation, and data management tasks when an SDF SuiteApp project is deployed to a target account.
For more information about the SDF installation script type in SuiteScript 2.1, see SuiteScript 2.1 SDF Installation Script Type.
Suitelet Script Type Differences
SuiteScript 2.1 Suitelets use the onRequest entry point. There is no equivalent event type in SuiteScript 1.0.
Suitelets run on the server in response to HTTP GET or POST requests. The params object provides request and response objects for processing the request and building the response.
For more information about the Suitelet script type in SuiteScript 2.1, see SuiteScript 2.1 Suitelet Script Type.
User Event Script Type Differences
Here's how user event scripts differ between SuiteScript 1.0 and 2.1:
-
The
beforeLoadentry point in SuiteScript 2.1 includes the parameter:newRecord. -
The
beforeSubmitentry point in SuiteScript 2.1 includes the parameters:oldRecordandnewRecord. -
The
afterSubmitentry point in SuiteScript 2.1 includes the parameters:oldRecordandnewRecord. -
The
typeparameter in each entry point in SuiteScript 2.1 is now set using thecontext.UserEventTypeenum.
For more information about the user event script type in SuiteScript 2.1, see SuiteScript 2.1 User Event Script Type.
Workflow Action Script Type Differences
Here's how workflow action scripts differ between SuiteScript 1.0 and 2.1:
-
In SuiteScript 2.1, a workflow action script includes the
onActionentry point. There is no equivalent event type in SuiteScript 1.0. -
The
idparameter in SuiteScript 1.0 isworkflowIdin SuiteScript 2.1. -
There are two parameters in SuiteScript 2.1:
newRecordandoldRecord.
For more information about the workflow action script type in SuiteScript 2.1, see SuiteScript 2.1 Workflow Action Script Type.