Hi there,
I’m using this script by @Justin_Barrett to batch duplicate some records:
This is what it looks like::
let table = base.getTable("TaskLog");
let query = await table.selectRecordsAsync()
let checked = query.records.filter(record => {return record.getCellValue("Copy") === true})
// Make new records based on those that were checked
let newRecords = []
for (let record of checked) {
let newRecord = {fields: {}}
for (let field of table.fields) {
// @ts-ignore
if (field.isComputed || field.name === "Copy")
continue
let value = record.getCellValue(field.name)
if (value === record.name)
value += ""
newRecord.fields[field.name] = value
}
newRecords.push(newRecord)
}
while (newRecords.length > 0) {
await table.createRecordsAsync(newRecords.slice(0, 50))
newRecords = newRecords.slice(50)
}
My question is:
How should I edit this script so that after the new duplicate records are created, the script will grab an input variable from a previous step in my automation and add it to all the new duplicate records that have just been created.

