Hey Airtable community,
I am having trouble automating a script that triggers when the quantity field is updated of a new record. The trigger action is that a record is inserted into another table (Inventory Quantities) with the id of the current table (Products) and quantity set to 0.
I had no issues when I set the field type of Product ID to number, but when I switched it to a linked record thats when the trouble started.
Please find the code below as per suggestions and documentation on how to handle linked records:
let ProductsTable = base.getTable("Products");
let QuantityTable = base.getTable("Inventory Quantities");
let query = await ProductsTable.selectRecordsAsync({
sorts: [
{field: "Product ID"},
]
});
let record = query.records[query.records.length-1];
let productID = record.getCellValue("Product ID") + '';
let newRecord = await QuantityTable.createRecordAsync({
"Product": [{id: productID }],
"Quantity": 0
})
This code throws Field “Product” cannot accept the provided value.
What could be causing this issue.
Thanks in advance for you assistance.