Hey there,
I have a script which:
- Takes the Qty of a product and creates rows in another table based on this qty.
- At the same time it maps 2 x Linked Record fields and sets the row ‘Status-’ to a pre-defined value.
The script is running wonderfully until the ‘Qty’ of a product starts to increase - for example I received the ‘Script exceeded execution time limit for 30 seconds’ error based on a qty of 380.
I’m a little confused at why this is occurring and wondering if anyone has any suggestions on the script posted below?
Thanks in advance.
let inputConfig = input.config()
let originalLineItem = inputConfig.originalLineItem
let originalProject = inputConfig.originalProject
let quantity= inputConfig.quantity
let tableToUpdate = base.getTable('Inventory Ledger')
let updates = new Array
for (let i = 0; i < quantity; i++){
updates.push({
"fields": {
"Stock! Linked": [{id:originalLineItem[0]}],
"Allocated to (remember late is best)": [{id:originalProject[0]}],
"Status-": {name: 'Forecast (we need at some point in the future)'},
}
})
}
while (updates.length > 0) {
await tableToUpdate.createRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50);
}
