Sam, thank you for this. It works! However, I donât seem to be able to launch it from the button. The script App opens but it doesnât run it. I added line 4 based on some guidance I found online but it didnât change anything. Here is what i have loaded:
//Tables
let table = base.getTable(âPartsâ);
let field = table.getField(âTest Buttonâ)
//Record Input
let record = await input.recordAsync(âPlease select a recordâ, table);
let cellValue = record.getCellValue(field);
//Record variables
let quantity = record.getCellValue(âReceivedâ);
let name = record.getCellValue(âNameâ);
let partNo = record.getCellValue(âPart Noâ);
let purchased = record.getCellValue(âPurchasedâ);
let cost = record.getCellValue(âCostâ);
let msrp = record.getCellValue(âMSRPâ);
//New record array
let recArray = ;
//Iterate by quantity
if(quantity > 1){
for(let i=0; i < quantity; i++){
//Push to the array
recArray.push({
fields: {
"Name": name,
"Part No": partNo,
"Purchased": purchased,
"Cost": cost,
"MSRP": msrp,
"Qty": 1
}
});
}
//Update the original record to have a quantity of 1
//table.updateRecordAsync(record, {
// "Qty": 1
//});
}
//Create new records
table.createRecordsAsync(recArray);