Structure of a Subrecord
The fields available in a subrecord vary depending on the subrecord’s type. Subrecords can have body fields, sublists, or both.
When working with subrecord fields, keep the following in mind:
-
After creating a subrecord, you can set values on its body and sublist fields using the same methods as for records.
-
Sublists within subrecords usually aren't 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 creating an address subrecord, you can set body field values using 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 creating a landed cost subrecord, you can set sublist field values using setSublistValue() and setCurrentSublistValue(), like you would with a record's sublist.
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. The subrecord has body fields for scheduling options, like whether purchase orders need to be created manually. It also has a sublist for entering dates for future purchase orders.

After creating an order schedule subrecord, you can set field values using the same methods as for records. Use setValue() for body fields. For sublist fields, use setCurrentSublistValue() or setSublistValue().
For more details, see Creating an Order Schedule Sublist Subrecord Example.