Does anyone have an idea on why this wont work?
# suitescript
c
Does anyone have an idea on why this wont work?
b
getAllResults returns an array
arrays dont have a run method
c
message has been deleted
wat datatype is this normally then?
b
not enough code to tell
c
its just a normal search
b
the guess would be a search.Search
c
,
which has a run function?
Hm, then i have to return a search object instead or what
Its because im limitied to 4000 search results returned at once, so i want to divide the search returns into blocks of a 1000
b
im not really gonna put much work into describing whats wrong with images of code
s
you could use NFT where that code is already written and unit tested. It would look something like this
Copy code
const allResults = Seq(LazySearch.from(mainItemSearch)).map(nsSearchResult2obj()).toArray()
b
the most obvious problem is that the second image of code assumes getAllResults returns a search.ResultSet
it doesnt, so you get your error
r
see if this helps, works for me
var searchResultCount = searchAll(revenueElementSearchObj.run());
Copy code
function searchAll(resultsetCurrent) {
    var allResults = [];
    var startIndex = 0;
    var RANGECOUNT = 1000;

    do {
      var pagedResults = resultsetCurrent.getRange({
        start: parseInt(startIndex),
        end: parseInt(startIndex + RANGECOUNT),
      });

      allResults = allResults.concat(pagedResults);
      var pagedResultsCount = pagedResults != null ? pagedResults.length : 0;
      startIndex += pagedResultsCount;

      var remainingUsage = runtime.getCurrentScript().getRemainingUsage();
      log.debug(remainingUsage);
    } while (pagedResultsCount == RANGECOUNT);
    var remainingUsage = runtime.getCurrentScript().getRemainingUsage();
    return allResults;
  }