Limit results or use maxRecords with Scripting App?

after using the API documentation it’s confusing trying to find info for the scripting app. I was expecting to be able to use maxRecords to grab the first record but that doesn’t seem to work. What am I missing here?

let queryResult = await table.selectRecordsAsync({
sorts: [
   // sort by "ID" in ascending order
   {field: "id"},
   // then by "Title" in descending order.
   {field: "title", direction: "desc"},
],
maxRecords: 1

});

Hi @Jared_Ingold - yeah the APIs are just different and maxRecords isn’t a param you can use in the scripting app. I’m sure you know this, but you can get to the same result with:

let table = base.getTable("Table");
let queryResult = await table.selectRecordsAsync();
let record = queryResult.getRecord(queryResult.recordIds[0]);
output.inspect(record.getCellValue("ID"));

I guess there’s an argument to say “why do I have to return all of the records in a table or view to get just one”, but for most bases (all?), this won’t be too much of an overhead.

=======================

Want to learn Airtable Scripting? 1 day bootcamp coming soon!

=======================

1 Like

I guess there’s an argument to say “why do I have to return all of the records in a table or view to get just one”, but for most bases (all?), this won’t be too much of an overhead.

To say the least; the record loading/base cloning times are arguably one of the most impressive aspects of Airtable.

Can’t say I ever came close to pushing both the 500-row and 50k-record limit in a single base, but this truly ain’t a major issue.