Patch 10 records at a time from an array of 100 records

Hello, i am setting up a Google Apps Script to update some records from our student information system. I was able to set up an array of records in the required format for patching the data in Airtable, i also got it to work, however whenever there are more than 10 records i get an error, so i am trying to figure out the best way to process them 10 at a time using plain JS or Google App Script. I was thinking of implementing a for loop to send a patch request for every record, but that did not seem like the smart way to do it. I wondering what was the best way to break it down 10 at a time


Standard practice for using Airtable Scripting’s .updateRecordsAsync() which lets you update 50 records at a time generally follows this format:

let updates = []

while (updates.length > 0) {
    await table.updateRecordsAsync(updates.slice(0, 50));
    updates = updates.slice(50);

So perhaps try

let updates = [] 

while (updates.length > 0) {
    base('Table Name').update(updates.slice(0, 10));
    updates = updates.slice(10);
1 Like

You will also need to make sure that you do not exceed the REST API rate limit of 5 requests per second. If you always wait until you get a response before sending the next batch, you will probably not exceed this rate limit. On the other hand, you might run into other limits from the GAS side. (I’m not familiar enough with GAS to say for sure.)


This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.