ANS-1355 · SUITESCRIPT DEVELOPMENT
How to Get Custom List Item Text Value in NetSuite SuiteScript 1.0
This guide explains how to extract the display text for custom list items when working with legacy SuiteScript 1.0 APIs in NetSuite.
Short answer
To retrieve the text value of a custom list item using SuiteScript 1.0 functions like nlapiSearchRecord or nlapiLookupField, specify 'name' as the column or field ID. This 'name' column holds the literal display value of the custom list entry, allowing scripts to access the human-readable text rather than just the internal ID.
Scenario
NetSuite users often store the internal ID of a custom list item on a record. When scripting, there is a need to retrieve the human-readable text value associated with that ID, rather than just the numerical identifier. This scenario typically arises when generating reports, displaying information on custom forms, or integrating with external systems.
Solution
To retrieve the literal text value of a custom list item when its internal ID is recorded on a NetSuite record, SuiteScript 1.0 functions such as nlapiSearchRecord and nlapiLookupField utilize 'name' as the column identifier for the text value.
For instance, when using nlapiLookupField to fetch the text value of a custom list item:
javascript
var customListItemText = nlapiLookupField('recordtype', recordId, 'customlistfieldid.name');When performing a search with nlapiSearchRecord and requiring the text value of a custom list item, include a search column referencing the custom list field's 'name':
javascript
var columns = [
new nlobjSearchColumn('customlistfieldid'),
new nlobjSearchColumn('customlistfieldid.name')
];
var searchResults = nlapiSearchRecord('recordtype', null, null, columns);
// To access the text value from a search result:
// var textValue = searchResults[0].getValue('customlistfieldid.name');It is important to note that nlapiSearchRecord and nlapiLookupField are functions within the legacy SuiteScript 1.0 API. While the method of using 'name' to retrieve the text value is accurate for SuiteScript 1.0, NetSuite's current development standard is SuiteScript 2.x, which employs different functions for similar data retrieval tasks.
Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
