I am attempting to transfer data from one field to another within a table that contains more than 10,000 records using the Scripting App, processing in batches of 50 records at a time. However, I am facing an issue with my code, as it only transfers the value from the first record. When I eliminate the await statement, it processes 15 records but then halts. Here is my code snippet:
let myTable = base.getTable('Vendors');
let myView = myTable.getView('Main View');
let myQuery = await myView.selectRecordsAsync();
let allRecords = myQuery.records;
processRecordBatches(allRecords);
async function processRecordBatches(allRecords) {
let index = 0;
while (index < allRecords.length) {
const batch = allRecords.slice(index, index + 50);
for (let entry of batch) {
let valueToCopy = entry.getCellValue('Merchant Name');
await myTable.updateRecordAsync(entry.id, { 'ImageBase64': valueToCopy });
}
index += 50;
}
}
Can anyone guide me on what I might be doing incorrectly here?