SuiteScript 1.0 APIs Not Directly Mapped to a SuiteScript 2.x Module

Some SuiteScript 1.0 functions and objects do not directly map to any SuiteScript 2.x module method, property, or enum. This includes SuiteScript 1.0 APIs that either do not have direct SuiteScript 2.x API equivalents or the mapping is not intuitive (such as a mapping from a method to a property, or to a new module altogether).

The following table provides the functions and objects that do not have direct or intuitive mapping to SuiteScript 2.x. This information is a summary of what is included in the SuiteScript 1.0 to SuiteScript 2.x API Map.

Refer to the SuiteScript 1.0 Documentation for information about SuiteScript 1.0 functions and objects.

SuiteScript 1.0 Function or Object

What to use when writing SuiteScript 2.x scripts

Functions

nlapiAddDays(d, days)

Standard JavaScript supplies date functions to add or subtract days from a Date object. SuiteScript 2.x is also compatible with third-party JavaScript APIs that provide date functions.

nlapiAddMonths(d, months)

Standard JavaScript supplies date functions to add or subtract months from a Date object. SuiteScript 2.x is also compatible with third-party JavaScript APIs that provide date functions.

nlapiEncrypt(s, algorithm, key)

Hashing and HMAC functionality are provided by the N/crypto Module. Encoding functionality is provided by the N/encode Module.

nlapiGetCurrentLineItemDateTimeValue(type, fieldId, timeZone)

This functionality is provided by the N/format Module. Specifically, the format.Timezone enum used in the format.format(options) and format.parse(options) methods.

nlapiGetDateTimeValue(fieldId, timeZone)

nlapiGetLineItemDateTimeValue(type, fieldId, lineNum, timeZone)

nlapiSetCurrentLineItemDateTimeValue(type, fieldId, dateTime, timeZone)

nlapiSetDateTimeValue(fieldId, dateTime, timeZone)

nlapiSetLineItemDateTimeValue(type, fieldId, lineNum, dateTime, timeZone)

nlapiSetRecoveryPoint()

Scripting recovery points for scheduled scripts are no longer necessary. See SuiteScript 2.x Scheduled Script Type and Map/Reduce Script Type Differences.

nlapiYieldScript()

Objects

nlobjCredentialBuilder.replace(string1, string2)

This functionality is not provided by a SuiteScript 2.x module or method. You need to manually perform the replacement of credential strings within your script.

nlobjPortlet.setRefreshInterval(n)

Although there is a Portlet object in SuiteScript 2.x, that object does not include a refresh function. It is no longer needed in SuiteScript 2.x scripts.

nlobjRecord.getCurrentLineItemDateTimeValue(type,fieldId, timeZone)

This functionality is provided by the N/format Module. Specifically, the format.format(options) and format.parse(options) methods.

nlobjRecord.getDateTimeValue(fieldId, timeZone)

nlobjRecord.getLineItemDateTimeValue(type, fieldId, lineNum, timeZone)

nlobjRecord.setCurrentLineItemDateTimeValue(type, fieldId, dateTime, timeZone)

nlobjRecord.setDateTimeValue(fieldId, dateTime, timeZone)

nlobjRecord.setLineItemDateTimeValue(type, fieldId, lineNum, dateTime, timeZone)

nlobjResponse.setContentType(type, name, disposition).

The functionality to specify content type and encoding type is specified using HTTP headers in SuiteScript 2.x. For more information, see HTTP Header Information and HTTPS Header Information.

nlobjResponse.setEncoding(encodingType).

nlobjSublist.setLineItemValues(values)

Use the Sublist.setSublistValue(options) method of the N/ui/serverWidget Module to set each value in the sublist individually.

nlobjSubrecord.cancel() and nlobjSubrecord.commit()

Scripting subrecords in SuiteScript 2.x is fundamentally different from scripting subrecords in SuiteScript 1.0. For more information about scripting subrecords in SuiteScript 2.x, see the help topics SuiteScript 2.x Scripting Subrecords and Subrecord Scripting in SuiteScript 2.x Compared With 1.0.

Along with functions and objects that are not directly mapped from SuiteScript 1.0 to SuiteScript 2.x, there are also some functions and objects in SuiteScript 1.0 that map to SuiteScript 2.x, but those mapping may not be intuitive. For example, the functions and objects provided to perform CSV imports in SuiteScript 1.0 are now provided by the N/task Samples in SuiteScript 2.x. All mappings are provided in the SuiteScript 1.0 to SuiteScript 2.x API Map. The map includes notes to aid in understanding mappings between SuiteScript 1.0 and SuiteScript 2.x that are not intuitive. Also refer to all help topics for the mapped SuiteScript 2.x modules to fully understand the difference (if any) in functionality provided by SuiteScript 1.0 and by SuiteScript 2.x.

Further, some SuiteScript 1.0 functions and objects map to SuiteScript 2.x module properties instead of module methods. The SuiteScript 1.0 to SuiteScript 2.x API Map clearly indicates these type of mappings. Look in the Notes column – it will indicate the mapping is to a SuiteScript 2.x module property.

If converting your SuiteScript 1.0 scripts to SuiteScript 2.x is not feasible in your situation, you can use SuiteScript 2.x RESTlet scripts to extend the capabilities of your existing SuiteScript 1.0 scripts. For more information, see Using SuiteScript 2.x Scripts with SuiteScript 1.0 Scripts.

Related Topics

General Notices