We can use record.getSublistValue(options) to get the sublist value.
| Method Description | Returns the value of a sublist field. Gets a numeric value for rate and ratehighprecision fields. |
| Returns | number | Date | string | array | boolean |
| Supported Script Types | Client and server scripts |
| Governance | None |
| Module | N/record Module |
| Sibling Object Members | Record Object Members |
| Since | 2015.2 |
Parameters
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
| options.sublistId | string | required | The internal ID of the sublist.This value is displayed in the Records Browser. |
| options.fieldId | string | required | The internal ID of a standard or custom sublist field. |
| options.line | number | required | The line number for the field. Note that line indexing begins at 0 with SuiteScript 2.0. |
Errors
| Error Code | Thrown If |
|---|---|
| SSS_INVALID_API_USAGE | Invoked prior to using setSublistValue in standard record mode. |
| SSS_INVALID_SUBLIST_OPERATION | A required argument is invalid or the sublist is not editable. |
| SSS_MISSING_REQD_ARGUMENT | A 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
});