The Smiling Coders

Netsuite Implementation, Support, Training and Integration

LOADING A SEARCH IN 2.0 SCRIPT AND OVERCOMING 1000 ROWS LIMIT

LOADING A SEARCH IN 2.0 SCRIPT AND OVERCOMING 1000 ROWS LIMIT

Category : SuiteScript 2.0

An existing search can be loaded or new one can be created in SuiteScript 2.0 and we can also over come the limitation of just 1000 rows being returned in one execution. Below code can be used for this:

var mysearch = search.load({

id: ‘8888’ // enter the existing search id (name or internal id)

});

var fil = search.createFilter({

name: ‘inactive’,

operator: ‘is’,

values: false

});

mysearch.filters.push(fil);

var customersearchResult = mysearch.run().getRange(0, 1000);

if(customersearchResult!=null&&customersearchResult!=”&&customersearchResult!=’ ‘)

{

var completeResultSet = customersearchResult; //copy the result

var start = 1000;

var last = 2000;

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

{

customersearchResult = mysearch.run().getRange(start_range, last_range);

completeResultSet = completeResultSet.concat(customersearchResult);

start = parseFloat(start)+1000;

last = parseFloat(last)+1000;

}

customersearchResult = completeResultSet;

log.debug({

title: ‘customer len’,

details: customersearchResult.length,

});

}

Feel free to reach out TheSmilingCoders for proper netsuite implementationnetsuite consultation , netsuite customization, netsuite Support,netsuite Trainingcontact us at:

Email : info@smilingcoders.com

Facebook : https://www.facebook.com/Smiling-Coders-Netsuite-Training-Implementation-and-Support-1591053827660082/

Linkedin : https://www.linkedin.com/company/netsuite-academy/


Leave a Reply

Reach Us @

Linkedin
Facebook
info@smilingcoders.com
+91 7306857196