SuiteScript 1.0 to 2.1 reference
nlapiCreateError in SuiteScript 2.1
In SuiteScript 2.1, nlapiCreateError is replaced by error.create from N/error. Creates a NetSuite error object to throw.
Before and after
// SuiteScript 1.0
throw nlapiCreateError('CREDIT_HOLD', 'Customer is on credit hold', true);// SuiteScript 2.1
define(['N/error'], (error) => {
throw error.create({ name: 'CREDIT_HOLD', message: 'Customer is on credit hold', notifyOff: true });
});What to watch for
- Catch blocks should read e.name and e.message; getCode() and getDetails() do not exist in 2.x.
Related functions
- nlapiLoadRecord becomes record.load
- nlapiCreateRecord becomes record.create
- nlapiSubmitRecord becomes record.save
- All SuiteScript 1.0 functions
Find what still needs converting
Find every script that still calls nlapiCreateError
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.