SuiteScript 1.0 to 2.1 reference
nlapiGetLineItemValue in SuiteScript 2.1
In SuiteScript 2.1, nlapiGetLineItemValue is replaced by getSublistValue from N/record. Reads a value from a sublist line.
Before and after
// SuiteScript 1.0
for (var i = 1; i <= nlapiGetLineItemCount('item'); i++) {
var qty = nlapiGetLineItemValue('item', 'quantity', i);
}// SuiteScript 2.1
const count = rec.getLineCount({ sublistId: 'item' });
for (let line = 0; line < count; line++) {
const qty = rec.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line });
}What to watch for
- Line numbers start at 0 in 2.1 and at 1 in 1.0. This is the most common silent bug in converted scripts.
- Loops written as i <= count must become line < count.
Related functions
- nlapiSetLineItemValue becomes setSublistValue
- nlapiSelectNewLineItem becomes selectNewLine
- nlapiGetNewRecord becomes context.newRecord
- All SuiteScript 1.0 functions
Find what still needs converting
Find every script that still calls nlapiGetLineItemValue
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.