Body Field Subrecords and Sublist Subrecords
When a subrecord occurs on a record, it is always represented by a single field on the record. In the SuiteScript Records Browser, this field is always listed as a field of type summary.
A field that contains a subrecord can exist either as a body or sublist field. For example, the subsidiary record has a body field called mainaddress, which stores an address subrecord. By contrast, the employee record permits the creation of multiple addresses, and each address is described in a sublist line. The sublist includes a field that contains the address subrecord instance.
This difference in where the summary field is placed affects the way you instantiate the subrecord.
For an example of each type of placement, see the following sections:
Subrecord that Occurs in a Sublist Field Example
Many subrecord types can occur in a sublist field.
For example, depending on the features enabled in your account, the item sublist of a purchase order record can include an Inventory Detail column. If the item on the line is a serialized or lot-numbered item, you can create a subrecord instance in this column.
In the UI, you can view and set values in this subrecord by clicking the icon in the Inventory Detail column. Clicking this icon opens a new window that represents the subrecord.
![Subrecord displayed from Inventory Detail icon.](img/SuiteCloudCustomizationScriptingWebServices/SuiteScript/SuiteScript20/SuiteScript20/invDetailSublistSubrecord.png)
Be aware that other fields on the sublist line are not part of the subrecord. For example, in the preceding screenshot, the values in the Item, Vendor Name, Received, Billed, and Quantity columns are not part of the subrecord.
For details on using SuiteScript 2.x to work with subrecords that exist on sublist lines, see Scripting Subrecords that Occur on Sublist Lines.
Subrecord that Occurs in a Body Field Example
A subrecord can also occur in a body field. In fact, the same type of subrecord that appears as a sublist field on one record type can appear as a body field on another record type.
For example, depending on the configuration of your account, the assembly build record can include an Inventory Detail body field. If the item in the record’s Assembly field is a serialized or lot-numbered inventory item, you can create an Inventory Detail subrecord in the Inventory Detail field.
In the UI, you can view and set values in this subrecord by clicking the icon under the Inventory Detail label and opening a new window.
![Subrecord displayed from Inventory Detail icon in the body field.](img/SuiteCloudCustomizationScriptingWebServices/SuiteScript/SuiteScript20/SuiteScript20/invDetailBodySubrecord.png)
For details on using SuiteScript 2.x to work with subrecords that exist in body fields, see Scripting Subrecords that Occur in Body Fields.