SuiteScript 1.0 to 2.1 reference
nlapiLookupField in SuiteScript 2.1
In SuiteScript 2.1, nlapiLookupField is replaced by search.lookupFields from N/search. Reads field values from a record without loading it.
Before and after
// SuiteScript 1.0
var terms = nlapiLookupField('customer', 42, 'terms'); // "3"
var name = nlapiLookupField('customer', 42, 'terms', true); // "Net 30"// SuiteScript 2.1
define(['N/search'], (search) => {
const { terms } = search.lookupFields({ type: 'customer', id: 42, columns: ['terms'] });
const termsId = terms[0] ? terms[0].value : ''; // "3"
const termsName = terms[0] ? terms[0].text : ''; // "Net 30"
});What to watch for
- Select fields come back as an array of { value, text } objects, not a string. Passing the array straight to setValue compiles and fails on save.
- Checkbox fields come back as booleans, and multi-select fields as arrays.
- There is no 'text' flag; read .text from the returned object instead.
Related functions
- nlapiDeleteRecord becomes record.delete
- nlapiTransformRecord becomes record.transform
- nlapiSearchRecord becomes search.create
- All SuiteScript 1.0 functions
Find what still needs converting
Find every script that still calls nlapiLookupField
SuiteMigrate lists the active 1.0 and 2.0 scripts in your NetSuite account, shows which ones you can read and which are locked, and drafts 2.1 conversions you review before deploying. Free for 5 conversions.
Examples are simplified. Test converted code in a NetSuite sandbox before deploying. SuiteMigrate is not affiliated with Oracle or NetSuite.