How to Get Sublist Value in SuiteScript

We can use record.getSublistValue(options) to get the sublist value.

Method DescriptionReturns the value of a sublist field. Gets a numeric value for rate and ratehighprecision fields.
Returnsnumber | Date | string | array | boolean
Supported Script TypesClient and server scripts
GovernanceNone
ModuleN/record Module
Sibling Object MembersRecord Object Members
Since2015.2

Parameters

ParameterTypeRequired / OptionalDescription
options.sublistIdstringrequiredThe internal ID of the sublist.This value is displayed in the Records Browser.
options.fieldIdstringrequiredThe internal ID of a standard or custom sublist field.
options.linenumberrequiredThe line number for the field. Note that line indexing begins at 0 with SuiteScript 2.0.

Errors

Error CodeThrown If
SSS_INVALID_API_USAGEInvoked prior to using setSublistValue in standard record mode.
SSS_INVALID_SUBLIST_OPERATIONA required argument is invalid or the sublist is not editable.
SSS_MISSING_REQD_ARGUMENTA required argument is missing or undefined.

Syntax

// Add additional code. …

var sublistFieldValue = objRecord.getSublistValue({

               sublistId: ‘item’,

               fieldId: ‘item’,

               line: 3

});

… // Add additional code.

Example

// Load the Sales Order record

let salesOrderRecord = record.load({

                type: record.Type.SALES_ORDER,

                id: salesOrderId, // Internal id of the sales order

                isDynamic: true           

});

// Get the value of the quantity field on the first line of the ‘item’ sublist           

let quantityValue = salesOrderRecord.getSublistValue({

                sublistId: ‘item’, // This value is displayed in the Records Browser.

                fieldId: ‘quantity’,

                line: 0           

});

Leave a comment

Your email address will not be published. Required fields are marked *