SuiteScript 1.0 to 2.1 reference

nlapiGetNewRecord in SuiteScript 2.1

In SuiteScript 2.1, nlapiGetNewRecord is replaced by context.newRecord from Entry point context. Gets the record being saved in a user event script.

Before and after

// SuiteScript 1.0
function beforeSubmit(type) {
  var rec = nlapiGetNewRecord();
  var old = nlapiGetOldRecord();
}
// SuiteScript 2.1
const beforeSubmit = (context) => {
  const rec = context.newRecord;
  const old = context.oldRecord; // null on create
};

What to watch for

  • The 1.0 type argument becomes context.type, compared with context.UserEventType.CREATE and so on.
  • nlapiGetRecordId() and nlapiGetRecordType() become rec.id and rec.type.

Related functions

Find what still needs converting

Find every script that still calls nlapiGetNewRecord

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.