We can use record.getSublistText(options) to get the sublist Text.
| Method Description | Returns the value of a sublist field in a text representation. Gets a string value with a “%” for rate and ratehighprecision fields. |
| Returns | string, For multiselect fields, returns an array. |
| Supported Script Types | Client and server scripts. Limitations exist on how this method can be used in standard (deferredDynamic) mode. In dynamic mode, you can use getSublistText() without limitation. |
| Governance | None |
| Module | N/record Module |
| Sibling Object Members | Record Object Members |
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. |
Syntax
// Add additional code. …
var sublistFieldName = objRecord.getSublistText({
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 display text of the item field on the first line of the ‘item’ sublist
let itemText = salesOrderRecord.getSublistText({
sublistId: ‘item’, // This value is displayed in the Records Browser.
fieldId: ‘item’,
line: 0
});