Home » Deeper in to NetSuite » How to Customize the NetSuite Search API?

How to Customize the NetSuite Search API?

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,
    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.

Get In Touch With Our Experts

    Heading to Display|Heading ID

    Get In Touch With Our Experts

      I have read and agree to the Privacy Policy of Folio3
      I agree to be contacted by Phone or Email by Folio3

      Get in touch with the


      End-to-end NetSuite Servicing Agency

      Tell us how may we assist you!