Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Apr 29, 2024 05:41 PM
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?
2 Replies 2
Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Apr 29, 2024 06:37 PM
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
Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎May 01, 2024 05:41 AM
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.
