Hi everyone,
I have no scripting knowledge and I have the below script from our community
SCRIPT
let table = base.getTable(“CopyRows”);
let query = await table.selectRecordsAsync();
let recordsArray = ;
for (let record of query.records) {
let quantity = record.getCellValue(“Quantity”);
if (quantity > 1) {
for (let i = 0; i < quantity-1; i++) {
recordsArray.push({
fields: {
“Name”: record.getCellValue(“Name”),
“Status”: record.getCellValue(“Status”),
“Quantity2”: record.getCellValue(“Quantity2”),
“Quantity”: quantity
}
})
}
}
let quantity2 = record.getCellValue(“Quantity2”);
if (quantity2 > 1) {
for (let i = 0; i < quantity2-1; i++) {
recordsArray.push({
fields: {
“Name”: record.getCellValue(“Name”),
“Status”: record.getCellValue(“Status”),
“Quantity”: record.getCellValue(“Quantity”),
“Quantity2”: 1
}
})
}
}
}
console.log(recordsArray);
let YOUR_TABLE = base.getTable(“YOUR_TABLE”);
let newRecords = await YOUR_TABLE.createRecordsAsync(recordsArray);
The script working fine for me except I would like to filter only records which contain certain values to be copied over to the other table.
For example: I have a columns name ‘Load Out No.’ with the values such as Load Out 1, Load Out 2, Load Out 3 etc.
I would love the script to prompt for input where I can enter ‘2’ as the value and only records with Load Out 2 being copied over.
Thanks in advance for all your help.