I’m trying to simply copy text from one column to another. Only about 20% of the records are being copied over. However the console logs each name correctly…
Im using this script, which i’ve edited for my own use from here:
// set the table
let table = base.getTable("Inventory Item Summary");
// get the table records
let itemCode = await table.selectRecordsAsync();
// loop through the records
for (let record of itemCode.records) {
// set variables to the record values
let itemCode = record.getCellValue("Item Code");
// only run on records which have notes
if (itemCode) {
output.text(`Copying notes for record ${record.name}`)
// build the newNotes value from the notes...
let newItemNumber = itemCode
table.updateRecordAsync(record, {
"Item Number": newItemNumber
})
}
}
Any help would be appreciated!
edit: i believe selectRecordsAsync() is deprecated, could this have something to do with it?
edit2: Doesn’t seem to be because of the deprecation, i changed it to:
let itemCode = await table.selectRecordsAsync({fields: ['Item Code']});
and still no change
edit 3:
Ive added an else statement, and it seems itemCode exists, and im not getting any ‘failed’ results
if (itemCode) {
output.text(`Copying notes for record ${record.name}`)
table.updateRecordAsync(record, {
"Item Number": itemCode
})
} else {
output.text('failed')
}