Differences in Similar SuiteScript 1.0 and SuiteScript 2.x Capabilities

Some SuiteScript 1.0 capabilities work differently in SuiteScript 2.x, such as logging, printing, scripting subrecords, and resolving URLs.

Logging

Instead of using the SuiteScript 1.0 nlapiLogExecution function to log all types of log messages, SuiteScript 2.x provides a different method for each type of log message: audit, debug, emergency, and error. Each method is available in the N/log Module.

  • The log.audit(options) method logs an audit message that appears on the Execution Log tab only if the Log Level on the script deployment is set to Audit or Debug.

  • The log.debug(options) method logs a debug message that appears on the Execution Log tab only if the Log Level on the script deployment is set to Debug.

  • The log.emergency(options) method logs an emergency message that appears on the Execution Log tab if the Log Level on the script deployment is set to Audit, Debug, Error, or Emergency. In other words, emergency messages always appear.

  • The log.error(options) method logs an error message that appears on the Execution Log tab only if the Log Level on the script deployment is set to Audit, Debug, or Error.

For more information, see the help topics:

Printing and Template Creation

Instead of using the SuiteScript 1.0 functions to print a record or create a template, in SuiteScript 2.x you use the methods in the N/render Module module, shown in the following table:

SuiteScript 1.0 Function

SuiteScript 2.x Method

nlapiCreateEmailMerger(templated)

render.mergeEmail(options)

nlapiCreateTemplateRenderer()

render.create()

nlapiPrintRecord(type, id, mode, properties)

render.bom(options), render.packingSlip(options), render.pickingTicket(options), render.statement(options), render.transaction(options)

nlapiXMLToPDF(xmlstring)

render.xmlToPdf(options), TemplateRenderer.renderAsPdf()

For more information, see N/render Module.

Scripting Subrecords

Scripting subrecords in SuiteScript 2.x is fundamentally different from scripting subrecords in SuiteScript 1.0. Compared with SuiteScript 1.0, SuiteScript 2.x introduces the following changes in how you script subrecords:

  • You can use a single method to create or load a subrecord

  • SuiteScript 2.x subrecords do not have to be explicitly saved; they are saved when you save the parent record

  • You must use subrecord methods to work with the address subrecord; addresses are not implemented using subrecords rather than individual fields on a record

For more information about scripting subrecords in SuiteScript 2.x, see SuiteScript 2.x Scripting Subrecords and Subrecord Scripting in SuiteScript 2.x Compared With 1.0.

Resolving URLs

Instead of using the SuiteScript 1.0 nlapiResolveURL function to resolve all URLs, SuiteScript 2.x provides a different method to resolve a record, a script, or a task. Each method is available in the N/url Module.

For more information about the methods available to resolve URLs, see N/url Module

Related Topics

General Notices