Work Around the 1000 Row Limit Returned by Saved Searches in Netsuite

nlapiSearchRecord can return only upto 1000 rows. But there is a work around to retrieve more than 1000 rows. This can be done by first sorting the result based on internal id and then using while loop and use concat method to get all results by internalid number as a filter inside the while loop. The sample code is given below:

var filters = new Array();

filters[1] = new nlobjSearchFilter('mainline',null,'is','T');

var columns = new Array();


columns[0] = new nlobjSearchColumn('internalid').setSort(); //sort the result based on internalid


var results = nlapiSearchRecord('transaction',null,filters,columns); //search record

var completeResultSet = results; //copy the result

while(results.length == 1000){ //if there are more than 1000 records

     var lastId = results[999].getValue('internalid'); //note the last record retrieved
     filters[2] = new nlobjSearchFilter('internalidnumber',null,'greaterthan',lastId); //create new filter to restrict the next search based on the last record returned
     results = nlapiSearchRecord('transaction',null,filters,columns);

     completeResultSet = completeResultSet.concat(results); //add the result to the complete result set 
}
 

Comments

  1. We are NetSuite Solution Provider with vast experience in NetSuite Implementation, netsuite customization including netsuite training & netsuite integration.
    NetSuite Solution Provider
    NetSuite Training
    NetSuite Implementation
    NetSuite Customization
    NetSuite Integration

    ReplyDelete

Post a Comment

Popular posts from this blog

USING CASE (IF AND ELSE) IN NETSUITE SAVED SEARCH- NETSUITE ACADEMY

Understand Core Technology behind SuiteScript 2.0