How to Get Sublist Text in SuiteScript

We can use record.getSublistText(options) to get the sublist Text.

Method DescriptionReturns the value of a sublist field in a text representation. Gets a string value with a “%” for rate and ratehighprecision fields.
Returnsstring, For multiselect fields, returns an array.
Supported Script TypesClient 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.
GovernanceNone
ModuleN/record Module
Sibling Object MembersRecord Object Members
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.
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           

});

Leave a comment

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