getAPIResultList(); appears to have a 1000 records restriction/limit.

Am using getAPIResultList() on a sheet with 1600+ entries/records but it only returns 1000. Why? And how do I code to process all records come what may?

Have answered my own question. Just discovered the setLimitSize() & setLimitFrom() functions which explains everything. Find it surprising that Ragic don’t offer a more elegant solution rather than all users having to code around this limitation.

1 Like

This is definitely not elegant, but the 1000 record limit can be handled with a function like this:

function retrieveAllRecordsWithPaging(queryUrl, filter) {
  var pageSize = 1000;
  var offset = 0;
  var combinedResults = [];

  while (true) {
    var query = db.getAPIQuery(queryUrl);
    query.setLimitFrom(offset);
    query.setLimitSize(pageSize);

    var queryResults = query.getAPIResultList();

    if (queryResults.length === 0) {
      break;
    }

    // combine array
    for (var i = 0; i < queryResults.length; i++) {
      combinedResults.push(queryResults[i]);
    }

    offset += queryResults.length;
  }

  return combinedResults;
}

Hope that helps someone. :slight_smile:

2 Likes