Posts

Showing posts from August, 2018

HOW TO CREATE A SEARCH IN SUITESCRIPT 2.0?

To create a search within any 2.0 script, we need to use search module and using its object create filters and columns and then run it. The following code can be used to create a search in 2.0 define(['N/record', 'N/search'], function(record, search) {         function execute(scriptContext) { var customersearch = search.create({ type: "customer", filters: [                                search.createFilter(                                                                    {                     name: 'isinactive',                     operator: 'is',         ...

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