Structure of a Subrecord
The fields available in a subrecord vary depending on the subrecord’s type. A subrecord can have body fields, a sublist, or both.
When working with a subrecord’s fields, be aware of the following:
-
After you instantiate a subrecord, you can set values on the subrecord’s body and sublist fields with the same methods as you would on a record.
-
In general, the sublists that exist within subrecords are not labeled in the UI. To find the name of a subrecord’s sublist, refer to the SuiteScript Records Browser. For details on using the Records Browser to find details on subrecords, see Finding Subrecord Details in the Records Browser.
For examples of subrecords that are structured in different ways, see the following sections:
Writable Body Fields Example
The address subrecord has several writable body fields, such as city, state, and zip. It has no sublist.

After you instantiate an address subrecord, you can set values for its body fields with the Record.setValue(options) method, the same as if you were setting values on an instance of a record. For more details, see Creating an Address Sublist Subrecord Example and Creating an Address on a Subsidiary Record Example.
Writable Sublist Example
The landed cost subrecord has a sublist that lets you list individual expenses associated with merchandise you have received. The body fields on this subrecord are read-only, but the sublist is writable. To add details about an expense, you add a line to the sublist.

After you instantiate a landed cost subrecord, you can set values for its sublist fields with the same methods you would to set values on a record’s sublist: setSublistValue() and setCurrentSublistValue().
For more details, see Creating a Landed Cost Sublist Subrecord Example.
Writable Body Fields and Sublist Example
The order schedule subrecord has a sublist that lets you configure how and when upcoming purchase orders are to be created. This subrecord has body fields that let you specify various qualities of the schedule, such as whether individual purchase orders must be created manually. It also has a sublist that lets you enter dates for the upcoming purchase orders.

Again, after you instantiate an order schedule subrecord, you can set values on its fields with the same methods you would use to set values on a record. For body fields, use setValue(). For sublist fields, use setCurrentSublistValue() or setSublistValue().
For more details, see Creating an Order Schedule Sublist Subrecord Example.