Skip to main content
Hey, I'm getting a time limit error for the below script only for some records. 
 
let table = base.getTable("Photos"); // Change "YourTableName" to your actual table name
let query = await table.selectRecordsAsync();

// Object to hold the count of each Claim-Fault combination
let counts = {};

// First pass to count occurrences
for (let record of query.records) {
    let claimNumber = record.getCellValue("Claim Number");
    let faultNumber = record.getCellValue("Fault No.");
    let identifier = `${claimNumber}-${faultNumber}`;

    if (counts[identifier]) {
        counts[identifier].push(record.id);
    } else {
        counts[identifier] = [record.id];
    }
}

// Second pass to update the Index field
for (let identifier in counts) {
    let recordIds = counts[identifier];
    for (let index in recordIds) {
        await table.updateRecordAsync(recordIds[index], {
            "Index": "." + index
        });
    }
}

console.log("Indexing complete.");
 
Is there anyway to extend the time limit?

Nope, there isn't a way to extend the limit I'm afraid.  Try optimizing your code by using `updateRecordsAsync` instead of `updateRecordAsync`, should solve the problem

https://airtable.com/developers/scripting/api/table#update-records-async


Hi,
Time limit exists in automations. Did you try to run it in script extensions?
I wonder what's the purpose of the script and what's the fields type.


If you can’t get your script down under the time limit, one of the easiest ways for working around this problem 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