Working with Sublists

Sublists are an important part of several NetSuite record types. In REST web services, you can use the POST and PATCH operations to access a sublist on a record instance. However, because sublists in NetSuite are of multiple types, for instance, editable sublist, applicaple sublist, or search sublist, each sublist can have slightly different behavior. Some sublists on particular records can even contain pre-generated lines. Moreover, if a line is added based on user input, it can contain default or computed values. Some sublists include one or more key fields that can uniquely identify each sublist record. These are keyed sublists. The behavior of keyed sublists is different from the behavior of non-keyed sublists.

Note:

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

The following list includes all operations that can be performed with a sublist:

  1. Add new

    • Single line

    • Multiple lines at once

  2. Update existing

    • Single line

    • Unset particular field

    • Multiple lines at once

  3. Remove existing

    • Single line – The delete operation is not available for removing single lines. You can delete a single line by using the patch operation, as in the following example:

                        PATCH /record/v1/purchaseOrder/:id?replace=item
      {
        „item": {
          „items": [
            { … all lines except those you want to delete … }
          ]
        }
      } 
      
                      
    • Multiple lines at once

    • All

  4. Mix (any combination of the above at once)

  5. Replace all

Operations 2.a, 2.b, 2.c, 3.a, 3.b, and 4 are not possible on non-keyed sublists. You can achieve the equivalent of these operations by replacing all sublist lines.

SOAP web services offer a special replaceAll attribute to enable some of these operations. For more information about this topic, see Updating Sublists in SOAP Web Services.

Similar behavior is also reflected in REST web services. This section provides details about each sublist operation mode.

In all the examples in this section, assume the following initial state of a record instance (unless otherwise specified).

          GET .../myrecord/100

{
    "body1": "previous body text 1",
    "body2": "previous body text 2",
    "sublist" : {
        "items" : [
            { "key1": "a", "key2": "1", "col": "previously present line 1" },
            { "key1": "b", "key2": "2", "col": "previously present line 2" },
            { "key1": "X", "key2": "0", "col": "previously present line 0" },
        ]
    },
    "unkeyedsublist" : {
        "items" : [
            { "col": "previously present line 1" },
            { "col": "previously present line 2" },
            { "col": "previously present line 0" },
        ]
    }
} 

        

See the following topics for more details:

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 Subrecords
Record Filtering and Query
Error Handling and Logging in REST Web Services

General Notices