Working with Subrecords

Subrecords represent a way of storing data in NetSuite. Like records, subrecords are classified by type. Some common types of subrecord include address, inventory detail, and order schedule.

A subrecord includes many of the same elements of a standard NetSuite record (body fields, sublists and sublist fields, and so on). However, subrecords must be created, edited, removed, or viewed from within the context of a standard (parent) record.

The purpose of a subrecord is to hold key related data about the parent record. For example, a parent record would be a Serialized Inventory Item record. This record defines a type of item. A subrecord would be an Inventory Detail subrecord. This is a subrecord that contains all data related to where the item might be stored in a warehouse. In this way, the subrecord contains data related to the item, but not data that directly defines the item. Without the parent record, the subrecord would serve no purpose. For more information about subrecords in general, see About Subrecords.

In REST web services, you can use the POST and PATCH operations to access a subrecord on the record instance.

Note:

For information about the format of subrecords in REST web services, see Format of Sublists and Subrecords.

Updating a Subrecord

Subrecords are modelled as inner JSON properties in the request and response body. In the following example, a subrecord, addressbookaddress is set on the sublist line of the addressbook sublist.

            POST http://demo123.suitetalk.api.netsuite.com/services/rest/record/v1/customer
 {
   "entityid": "My Customer",
   "companyname": "My Company",
   "email": "another.customer@example.com",
   "addressbook": {
       "items": [{
           "label": "New York HQ",
           "addressbookaddress": {
               "country": "US",
               "state": "NY",
               "zip": "10001",
               "addressee": "Dwight Schrute"
           }
       }]
   }
 } 

          

Getting a Subrecord

The following example shows a GET operation, which is used to access a subrecord.

            GET http://demo123.suitetalk.api.netsuite.com/services/rest/record/v1/customer/42/addressbook/24/addessbookaddress 
{
    "addressee": "Dwight Schrute",
    "city": "New York",
    "country": "US",
    "dropdownstate": {
        "id": "NY",
        "refName": "New York",
        ...
    },
    "state": "NY",
    "zip": "10001",
    ...
} 

          

The structure of the subrecord is also returned on the parent record, on the sublist line, if you set the expandSubResources query parameter to true.

Related Topics

SuiteTalk REST Web Services Overview and Setup
Authentication and Session Management for REST Web Services
REST Web Services Request Processing
Working with REST Web Services Using Postman
Working with Resource Metadata
Working with Records
Working with Sublists
Record Filtering and Query
Error Handling and Logging in REST Web Services

General Notices