Modules

filter

 

Objects/Functions

module (N/search)

SuiteScript 2.0

search.lookupFields(options)

{search}.lookupFields({type: {enum},id: {string},columns: {string | string[]}})

N/search Module
search.lookupFields()
Method Description: Performs a search for one or more body fields on a record. You can use joined-field lookups with this method, with the following syntax: join_id.field_name The search.lookupFields(options) method also includes a promise version, search.lookupFields.promise(options). For more information about promises, see Promise Object. Note that the return contains either an object or a scalar value, depending on whether the looked-up field holds a single value, or a collection of values. Single select fields are returned as an object with value and text properties. Multi-select fields are returned as an object with value:text pairs. In the following example, a select field like my_select would return an array of objects containing a value and text property. This select field contains multiple entries to select from, so each entry would have a numerical id (the value) and a text display (the text). For "internalid" in this particular code snippet, the sample returns 1234. The internal id of a record is a single value, so a scalar is returned. If you try to look up a field that does not exist on the specified record, an SSS_INVALID_SRCH_COL error is thrown.
Returns: Object | Object[] Returns select fields as an object with value and text properties. Returns multiselect fields as an array of object with value:text pairs.
Supported Script Types: All script types For more information, see SuiteScript 2.0 Script Types.
Governance: 1 unit
Module: N/search Module
Since: 2015.2
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=search.lookupFields(options)

Example:

// Code Example 1
{
internalid: 1234,
firstname: 'Joe',
my_select: [{
value: 1,
text: 'US Sub'
}],
my_multiselect: [
{
value: 1,
text: 'US Sub'
},
{
value: 2,
text: 'EU Sub'
}
]
}

// Code Example 2
//Add additional code
//...
var fieldLookUp = search.lookupFields({
type: search.Type.SALES_ORDER,
id: '87',
columns: ['entity', 'subsidiary', 'name', 'currency']
});
//...
//Add additional code

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4345776651.html