I have a script that has been working for over a year, but now will not update records. I sync a table from another base to a second tab in main base. I then use the following script I was given over a year ago (can't remember where I got it). It has worked great to look at the synced tab to see a unique ID (emp #) and then pull that onto the main table and pull multiple records from the syned tab.
Now when I run it the script runs super fast and doesn't update anything even though I have matching Unique IDs.
Here is the script I am using:
//Substitute "Orders" for table name which contains values
//on which you want to run the vlookup
let mainTable = base.getTable("Covid LOA");
let mainTableRecords =await mainTable.selectRecordsAsync({fields:["emp"]});
//Substitute "Product" for table which contains range to search in
let lookupTable = base.getTable("Proof");
let lookupRangeRecords =await lookupTable.selectRecordsAsync({fields:["Emp"]});
//Replace "Item.barcode" with column name which has the values you want to look up
for(let record of mainTableRecords.records){
let lookupValue = record.getCellValue("emp");
//Replace "Barcode" with column name which is the range to search in
for(let rangeRecord of lookupRangeRecords.records){
//Replace "Product" with column name from mainTable which should contain the link
await mainTable.updateRecordAsync(record,{
"COVID FMLA Proof":[{id: linkID}]
});
}
}
}
Best answer by kuovonne
When a script that has been working stops working, the first thing I look at is any schema changes that may have happened. Seemingly minor changes to field types can have big impacts to scripts. I’m guessing that you are not seeing any record updates because the script is not finding any matches, possibly due to the field types of the {emp} and {Emp} fields.
By the way, this particular script looks like it is a rather inefficient script. That may not be a problem as you are probably running it in scripting extension and not as an automation.
When a script that has been working stops working, the first thing I look at is any schema changes that may have happened. Seemingly minor changes to field types can have big impacts to scripts. I’m guessing that you are not seeing any record updates because the script is not finding any matches, possibly due to the field types of the {emp} and {Emp} fields.
By the way, this particular script looks like it is a rather inefficient script. That may not be a problem as you are probably running it in scripting extension and not as an automation.
When a script that has been working stops working, the first thing I look at is any schema changes that may have happened. Seemingly minor changes to field types can have big impacts to scripts. I’m guessing that you are not seeing any record updates because the script is not finding any matches, possibly due to the field types of the {emp} and {Emp} fields.
By the way, this particular script looks like it is a rather inefficient script. That may not be a problem as you are probably running it in scripting extension and not as an automation.
I'll take a look at field types.
As for how I am running it, yes I am running it through Extensions as I don't know how to run as Automation within Airtable. Any help guides or videos to help learn this?
When a script that has been working stops working, the first thing I look at is any schema changes that may have happened. Seemingly minor changes to field types can have big impacts to scripts. I’m guessing that you are not seeing any record updates because the script is not finding any matches, possibly due to the field types of the {emp} and {Emp} fields.
By the way, this particular script looks like it is a rather inefficient script. That may not be a problem as you are probably running it in scripting extension and not as an automation.