Subrecord Scripting in SuiteScript 2.x Compared With 1.0

Compared with SuiteScript 1.0, SuiteScript 2.x introduces the following changes in how you script subrecords:

A Single Method Lets You Create and Load Subrecords

In SuiteScript 1.0, there are separate APIs for creating and editing subrecords. For example, you'd use nlapiCreateSubrecord to create a subrecord and nlapiEditSubrecord to edit a subrecord.

In SuiteScript 2.x, the same method can create or edit a subrecord. These methods all have the word get in their names. For example, you use the getSubrecord() method to create or load a subrecord that exists on the body of a record. You use the getSublistSubrecord() or getCurrentSublistSubrecord() method to create or load a subrecord that exists on a sublist line.

When you use any of these methods, the system responds with the following logic:

Subrecords Do Not Have to Be Explicitly Saved

In SuiteScript 1.0, you had to explicitly save a subrecord before saving the record. However, in SuiteScript 2.x, after you create a subrecord or make changes to one, you are not required to explicitly save the subrecord (and no methods exist for that purpose). New subrecords are saved when you save the record. This also applies if you update an existing subrecord. Updates are saved when you save the record.

To Create Addresses, You Must Use Subrecord Methods

Before address subrecords existed, addresses were represented as body fields or sublist lines on records.

After address subrecords were introduced, SuiteScript 1.0 was updated to support two ways of working with addresses:

In SuiteScript 2.x, you must use subrecord methods to create an address. The system doesn't support the old address body and sublist fields. For that reason, to create, edit, or load an address in SuiteScript 2.x, you must instantiate the address subrecord by referencing the appropriate summary field.

Related Topics

General Notices