UI and Record Script Type Differences

Client, portlet, Suitelet, user event, and workflow action scripts respond to user-interface, record, or workflow activity.

The following sections compare these script types in SuiteScript 1.0 and SuiteScript 2.1:

Client Script Type Differences

When you convert a client script from SuiteScript 1.0 to 2.1, these event names and arguments change:

  • The SuiteScript 1.0 pageInit argument type corresponds to the SuiteScript 2.1 context property mode.

  • For fieldChanged and validateField, the SuiteScript 1.0 type, name, and linenum arguments correspond to the SuiteScript 2.1 sublistId, fieldId, and line properties, respectively.

  • For sublist fields, SuiteScript 1.0 linenum starts at 1, while SuiteScript 2.1 line starts at 0. Adjust line-number logic when converting these scripts.

  • The SuiteScript 1.0 recalc event corresponds to the SuiteScript 2.1 sublistChanged entry point.

SuiteScript 2.1 also adds these context properties and entry points:

  • Client script entry point context objects include the currentRecord property.

  • The context objects passed to the fieldChanged and validateField entry points include the column property.

  • The context object passed to the validateDelete entry point includes the lineCount property.

  • Client scripts include the localizationContextEnter and localizationContextExit entry points.

SuiteScript 2.1 client scripts run in the browser. Use JavaScript features supported by your users' browsers.

For more information about the client script type in SuiteScript 2.1, see SuiteScript 2.1 Client Script Type.

Portlet Script Type Differences

At the script level, portlets differ between SuiteScript 1.0 and 2.1 in these ways:

  • In SuiteScript 2.1, a portlet script includes the render entry point. There is no equivalent event type in SuiteScript 1.0.

  • In SuiteScript 1.0, NetSuite passes the portlet object and dashboard column index as separate arguments to the portlet function. In SuiteScript 2.1, the render entry point receives them through params.portlet and params.column.

On the SuiteScript 2.1 Portlet object, these methods and properties change:

  • The SuiteScript 1.0 nlobjPortlet.setRefreshInterval(n) method is not available on the SuiteScript 2.1 Portlet object.

  • The SuiteScript 1.0 nlobjPortlet methods setHtml(html) and setTitle(title) correspond to the SuiteScript 2.1 Portlet.html and Portlet.title properties, respectively.

  • The SuiteScript 1.0 setScript(scriptid) method is not available on the SuiteScript 2.1 Portlet object. To associate a client script with a portlet, use Portlet.clientScriptFileId or Portlet.clientScriptModulePath. These properties identify a script file or module path, not a script record ID.

Method arguments also change:

  • The SuiteScript 1.0 nlobjPortlet.addColumn(name, type, label, just) method takes individual arguments, while the SuiteScript 2.1 Portlet.addColumn(options) method takes an options object. The name and just arguments correspond to options.id and options.align, respectively.

  • The SuiteScript 1.0 nlobjPortlet.addEditColumn(column, showView, showHrefCol) method takes an nlobjColumn object for column. In SuiteScript 2.1, Portlet.addEditColumn(options) takes a column ID in options.column and supports the additional optional properties options.link, options.linkParam, and options.linkParamName.

  • The name argument of the SuiteScript 1.0 nlobjPortlet.addField(name, type, label, source) method corresponds to options.id in the SuiteScript 2.1 Portlet.addField(options) method.

  • The indent argument of the SuiteScript 1.0 nlobjPortlet.addLine(text, url, indent) method corresponds to options.align in the SuiteScript 2.1 Portlet.addLine(options) method. Both specify an indent level from 0 to 5.

For more information about the portlet script type in SuiteScript 2.1, see SuiteScript 2.1 Portlet Script Type.

Suitelet Script Type Differences

A SuiteScript 1.0 Suitelet function receives separate request and response arguments. In SuiteScript 2.1, the onRequest entry point receives a context object with request and response properties. Suitelets run on the server in both versions.

In SuiteScript 1.0, call setScript(script) on the form, list, or assistant object and pass the client script's script ID. In SuiteScript 2.1, use the corresponding object's clientScriptFileId or clientScriptModulePath property to identify the client script file or module path.

For more information about the Suitelet script type in SuiteScript 2.1, see SuiteScript 2.1 Suitelet Script Type.

User Event Script Type Differences

User event functions have similar triggers in both versions, but receive event data differently:

  • SuiteScript 1.0 passes type and form as separate arguments to a beforeLoad function. SuiteScript 2.1 passes a context object with context.type and context.form properties.

  • In beforeLoad, the SuiteScript 1.0 request argument corresponds to SuiteScript 2.1 context.request. This value is available for browser requests, but not when a server triggers the event.

  • The SuiteScript 1.0 nlapiGetNewRecord() function corresponds to context.newRecord in the SuiteScript 2.1 beforeLoad, beforeSubmit, and afterSubmit entry points.

  • The SuiteScript 1.0 nlapiGetOldRecord() function is documented for beforeLoad, beforeSubmit, and afterSubmit. In SuiteScript 2.1, the beforeSubmit and afterSubmit context objects include context.oldRecord, but the beforeLoad context object does not.

  • SuiteScript 1.0 passes the event type as a type argument to each user event function. In SuiteScript 2.1, context.type identifies the event type. Compare it with values from the context.UserEventType enum when branching your script logic.

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 onAction entry point. There is no equivalent event type in SuiteScript 1.0.

  • The id argument in SuiteScript 1.0 corresponds to the workflowId property of the SuiteScript 2.1 onAction context object.

  • The SuiteScript 1.0 form argument corresponds to scriptContext.form in SuiteScript 2.1. The form is available only in the beforeLoad context.

  • The SuiteScript 1.0 type argument corresponds to scriptContext.type in SuiteScript 2.1.

  • The SuiteScript 2.1 onAction context object includes the newRecord and oldRecord properties.

For more information about the workflow action script type in SuiteScript 2.1, see SuiteScript 2.1 Workflow Action Script Type.

Related Topics

General Notices