SuiteScript 1.0 to 2.1 reference
nlapiCreateRecord in SuiteScript 2.1
In SuiteScript 2.1, nlapiCreateRecord is replaced by record.create from N/record. Creates a new record in memory. Nothing is saved until you call save().
Before and after
// SuiteScript 1.0
var rec = nlapiCreateRecord('customer');
rec.setFieldValue('companyname', 'Acme');
var id = nlapiSubmitRecord(rec);// SuiteScript 2.1
define(['N/record'], (record) => {
const rec = record.create({ type: record.Type.CUSTOMER });
rec.setValue({ fieldId: 'companyname', value: 'Acme' });
const id = rec.save();
});What to watch for
- Initial values that 1.0 passed as the third argument go in defaultValues.
- Create with isDynamic: true if later code depends on field sourcing as values are set.
Related functions
- nlapiSubmitRecord becomes record.save
- nlapiSubmitField becomes record.submitFields
- nlapiLookupField becomes search.lookupFields
- All SuiteScript 1.0 functions
Find what still needs converting
Find every script that still calls nlapiCreateRecord
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.