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) {
if (rangeRecord.getCellValue("Emp") === lookupValue) {
let linkID = rangeRecord.id;
//Replace "Product" with column name from mainTable which should contain the link
await mainTable.updateRecordAsync(record, {
"COVID FMLA Proof": [{id: linkID}]
});
}
}
}