Help

Scripting App Vs. "Run a Script" Automation

Topic Labels: Automations
Solved
Jump to Solution
1834 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Sam_Becker
5 - Automation Enthusiast
5 - Automation Enthusiast

Hello All,

I have the following script that I use to create links between tables based on the “ID,” which is consistent between the two tables. Typically, I run this script manually every few days or so, but I have recently discovered the “Run a Script” automation, which would completely eliminate the need for manually clicking the “Run Script” button. However, the following script throws an error every time I test the automation (which is when a new record in the “Enrollment” table is created, the script is supposed to run). I’ve gathered that this is an issue with certain functions not being recognized in the automation, however I do not know how to fix this. Any help would be greatly appreciated!

//Define the Facilities table and query
var facTbl = base.getTable(“Facilities”);
var facQuery = await facTbl.selectRecordsAsync();

//Define Enrollment table and query
var conTbl = base.getTable(“Enrollment”);
var conQuery = await conTbl.selectRecordsAsync();

// Create an updates array
let updates = ;

//Loop through the records of Facilities
for (let facRecord of facQuery.records) {
let FacTpID = facRecord.getCellValue(“ID”);
let Sources = ;
//Loop through the records of Results table
for (let resRecord of conQuery.records) {
if (resRecord.getCellValue(“ID”) === FacTpID) {
Sources = […Sources,{id: resRecord.id}]
}
}
// Push update into the updates array
updates.push({
id: facRecord.id,
fields: {
‘Enrollment’: […Sources]
}
});
}
// Update records
while (updates.length > 0) {
await facTbl.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50)}

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

Scripts are having issues right now. I suggest you wait until Airtable status is back to normal before resuming your development.

See Solution in Thread

2 Replies 2
kuovonne
18 - Pluto
18 - Pluto

Scripts are having issues right now. I suggest you wait until Airtable status is back to normal before resuming your development.

Hi kuovonne,

Thanks for your reply! I saw that the Airtable team just fixed the scripts issue and the automation is now running perfectly. Thank you for your reply!