How to Customize the NetSuite Search API?

Table of Contents

Stay Updated

Subscribe to get the latest news, industry trends, blog posts, and updates...

In this post I’ll show you how to customize the Search API in NetSuite to search for more than 1000 records. As you know, NetSuite provides an in-built search method for retrieving supported records by using the nlapiSearchRecord API. The only limitation of this API is that can only search through 1000 rows at a time. This can be a problem when you want to search for more than 1000 records, for instance, for performing some calculation.

CTA - NetSuite Implementation Banner

You can work around this limitation by tweaking the script  of (customizing) the Search API, thereby enabling it to search for more than a thousand records. Let’s look at an example.

In the code snippet below, I have customized the Search API script to fetch more than a thousand customer records.

var search = nlapiCreateSearch('customer'),
    searchResults = search.runSearch(),
    resultIndex = 0,
    resultStep = 1000,
    resultSet,
    resultSets = [];

do {
    resultSet = searchResults.getResults(resultIndex, resultIndex + resultStep);
    resultSets = resultSets.concat(resultSet);
    resultIndex = resultIndex + resultStep;
} while (resultSet.length > 0);
CTA - NetSuite Customization Banner

As you can see, in the above case resultSets will display all the rows if more than 1000 rows exist for this query. In the same way, you can create a generalized search function to search for 1000+ records in NetSuite. Now that you know how to customize the NetSuite Search API, you can read our full guide on API Integration and What is an API.

Related resources you might be interested in

Do you have similar NetSuite implementation, integrations or customization needs?

Folio3 Your Top Choice:

Let's discuss your NetSuite needs

Hello, How can we help you?