Skip to main content
Solved

Scripting App Vs. "Run a Script" Automation


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)}

Best answer by kuovonne

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

View original
Did this topic help you find an answer to your question?

2 replies

kuovonne
Forum|alt.badge.img+17
  • Brainy
  • 5996 replies
  • Answer
  • September 16, 2021

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


  • Author
  • Participating Frequently
  • 5 replies
  • September 16, 2021
kuovonne wrote:

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!


Reply