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](https://netsuite.folio3.com/wp-content/uploads/2021/11/CTA-NetSuite-Implementation-Banner.jpg)
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);
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.