SuiteScript 1.0 to 2.1 reference

nlapiSelectNewLineItem in SuiteScript 2.1

In SuiteScript 2.1, nlapiSelectNewLineItem is replaced by selectNewLine from N/currentRecord or dynamic N/record. Adds a line to a sublist in dynamic mode or a client script.

Before and after

// SuiteScript 1.0
nlapiSelectNewLineItem('item');
nlapiSetCurrentLineItemValue('item', 'item', 55);
nlapiSetCurrentLineItemValue('item', 'quantity', 2);
nlapiCommitLineItem('item');
// SuiteScript 2.1
const rec = context.currentRecord;
rec.selectNewLine({ sublistId: 'item' });
rec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: 55 });
rec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: 2 });
rec.commitLine({ sublistId: 'item' });

What to watch for

  • On a server-side record this works only when it was loaded or created with isDynamic: true.

Related functions

Find what still needs converting

Find every script that still calls nlapiSelectNewLineItem

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.

Add to Chrome — freeRead the migration guide

Examples are simplified. Test converted code in a NetSuite sandbox before deploying. SuiteMigrate is not affiliated with Oracle or NetSuite.