LOADING A SEARCH IN 2.0 SCRIPT AND OVERCOMING 1000 ROWS LIMIT

An existing search can be loaded or new one can be created in 2.0 script 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,



});

}




For Netsuite Training (Including training for interviews), Support, Implementation contact us at:

Email :
netsuiteacademy@netsuite-academy.com
Facebook page : https://www.facebook.com/Netsuite-Academy-1591053827660082/

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

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

Understand Core Technology behind SuiteScript 2.0

HOW TO SET SUBLIST SUB RECORD VALUES IN SUITE SCRIPT 1.0 AND 2.0