Hello, I have a suitescript using a saved search's...
# suitescript
j
Hello, I have a suitescript using a saved search's results and some of them are exceeding 4000 now so it's givng the error: "JS_EXCEPTION SSS_SEARCH_FOR_EACH_LIMIT_EXCEEDED No more than 4000 search results may be returned at one time"... Would Map/Reduce be a good option for this, is there a simple way to limit the search temporarily? I would appreciate any insight.
b
use Search.runPaged instead
j
Thanks so much! I am not super familiar with these scripts yet, does this look like the right place to change that in?
Copy code
duplicatePOSearch.filters.push(customerFilter);
      
          log.debug('duplicatePOSearch filters', duplicatePOSearch.filters);
      
          duplicatePOSearch.run().each(function (result) { 

            customerPOs.push({
              
                soInternalId: result.id,
                soDocNum: result.getValue('tranid'),
                soPONum: result.getValue('otherrefnum').trim().toLowerCase(),

            });

            return true;
b
its not a drop in replacement, it gets results differently than the result set's each method
but you are in the right place, that is your search code
s
@Jeremy Dean
Copy code
var searchObj = search.load({
  id: "customsearch_1",
});
var list = [];
var page;
var pagedData;
var additionalFilterExpression = [
  ["isinactive", "is", "F"],
  "AND",
  ["subsidiary", "anyof", params.subsidiaries],
  "AND",
  ["date", "before", searchDate],
];
if (params.department) {
  additionalFilterExpression.push("AND");
  additionalFilterExpression.push(["department", "is", params.department]);
}
if (params.class) {
  additionalFilterExpression.push("AND");
  additionalFilterExpression.push(["class", "is", params.class]);
}
if (params.location) {
  additionalFilterExpression.push("AND");
  additionalFilterExpression.push(["location", "is", params.location]);
}
searchObj.filterExpression = searchObj.filterExpression.concat(additionalFilterExpression);
pagedData = searchObj.runPaged({pageSize: 1000});
pagedData.pageRanges.forEach(function(pageRange) {
  page = pagedData.fetch({index: pageRange.index});
  page.data.forEach(function(row) {

    list.push({
      a:row.getValue('');

    })
    return true;
  });
  return true;
});
this is what I'll do, hope it helps
j
Thank you both
👍 1