SuiteScript 1.0 to 2.1 reference

nlapiSearchRecord in SuiteScript 2.1

In SuiteScript 2.1, nlapiSearchRecord is replaced by search.create from N/search. Runs a search with filters and columns.

Before and after

// SuiteScript 1.0
var filters = [new nlobjSearchFilter('status', null, 'anyof', 'SalesOrd:B')];
var columns = [new nlobjSearchColumn('tranid')];
var results = nlapiSearchRecord('salesorder', null, filters, columns) || [];
// SuiteScript 2.1
define(['N/search'], (search) => {
  const results = [];
  search.create({
    type: search.Type.SALES_ORDER,
    filters: [['status', 'anyof', 'SalesOrd:B'], 'AND', ['mainline', 'is', 'T']],
    columns: ['tranid'],
  }).run().each((result) => {
    results.push(result.getValue({ name: 'tranid' }));
    return true; // keep iterating
  });
});

What to watch for

  • 1.0 returned null for no results; 2.1 returns an empty result set, so the || [] guard is no longer needed.
  • run().each() stops at 4,000 results. Use runPaged() for larger result sets.
  • Add a mainline filter on transaction searches if the 1.0 search relied on one line per transaction.

Related functions

Find what still needs converting

Find every script that still calls nlapiSearchRecord

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.