I am trying to write a script that will look at 4 fields from an older version, and copy the contents of those 4 fields to a newer version of the same data.
When I run this, the script finishes super fast, and no records are updated. I know that some matches are being found due to the console.log statement. However, when I check my table that is supposed to be receiving the updates, there are no changes.
What is going wrong when I try to update the records?
let oldTable = base.getTable("Updated 4/15/21");
let newTable = base.getTable("Imported 4/29/21");
let oldRecordsQuery = await oldTable.selectRecordsAsync();
let newRecordsQuery = await newTable.selectRecordsAsync();
let oldRecords = oldRecordsQuery.records;
let newRecords = newRecordsQuery.records;
newRecords.forEach((record) => {
let found = oldRecords.find((old) => old.name === record.name);
console.log(found);
if (found) {
let newCalledBy = found.getCellValueAsString("Called By");
let newCalled = found.getCellValue("Called?");
let newTexted = found.getCellValue("Texted?");
let newNotes = found.getCellValueAsString("Notes");
newTable.updateRecordAsync(record, {
"Called By": newCalledBy,
"Called?": newCalled,
"Texted?": newTexted,
"Notes": newNotes,
});
}
});