Skip to main content

Hi All,

I’m trying to run this automation script that works perfectly on my test base of ~10 records but throws this error when I move it to my real base with ~1100 records.

Error: Script exceeded execution time limit of 30 seconds

The below code is based on this tutorial here, tweaked slightly with recommendations I found in another similar question. Any help or ideas would be appreciated!
Learn Airtable scripting #1: basics & removing duplicates with Giovanni Briggs - YouTube (from Automate All the Things channel)

var table = base.getTable(“Table 1”);

var query = await table.selectRecordsAsync ({

fields: ["Name" ]

});

console.log(query);

let duplicates = query.records.filter((record)=>{

return query.records.find((potentialDuplicate)=>{

   return record.getCellValue("Name") === potentialDuplicate.getCellValue("Name") && record.id !== potentialDuplicate.id;

})

});

console.log(duplicates);

let updates = duplicates.map(update => {

return {

    "id":update.id,

    fields: {

        "Duplicate": true

    }

}

})

console.log(updates);

while (updates.length>0){

//removed await in front of the below Async to see if that would improve time

table.updateRecordsAsync(updates.slice(0,50));

updates = updates.slice(50);

};

Not surprising - think that snippet makes (1100-1)->squared calls to try to find duplicates. e.g., for each row, look at the other 1099 rows - really bad design.

You need to use hash indices to do this fast.


Not surprising - think that snippet makes (1100-1)->squared calls to try to find duplicates. e.g., for each row, look at the other 1099 rows - really bad design.

You need to use hash indices to do this fast.


Thanks! I will try it out.


On a different note…

All asynchronous methods must use await to function correctly. It’s possible that some updates might not get saved correctly if not await-ed.


Your best bet for working around the problem of script execution timeout limits is to outsource your automation to Make’s advanced automations & integrations for Airtable.

The execution timeout limit with Make is 40 minutes per automation.

Here is one of the ways that you can instantly trigger a Make automation from Airtable

What’s really awesome about Make is:

  1. Make is a no-code platform, so you can create all sorts of advanced automations & app integrations without writing any code at all.
  2. But what’s even more exciting is that if you DO want to write your own Javascript code, that is natively supported by Make’s Code module.

If you’ve never used Make before, I’ve assembled a bunch of Make training resources in this thread. I also give live demonstrations of how to use Make in many of my Airtable podcast appearances. For example, in this video, I show how to work with Airtable arrays in Make.

Hope this helps!

If you’d like to hire the best Airtable consultant to help you with anything Airtable-related, please feel free to contact me through my website: Airtable consultant — ScottWorld