Apr 22, 2020 10:10 AM
I would like to create a script that creates a number of records based on a quantity field. Essentially, if there is a record that has a quantity (x) of more than 1, I want to copy and create that record x amount of times within the table, then lower the quantity for the record and each subsequent record to 1.
I have some of the script set up. Are there any ideas on how I could specify the # of records to create, based on the quantity field, using createRecordsAsync in the Scripting Block?
As usual, thanks for the help!
Oct 10, 2022 04:41 PM
Hi,
you missed for loop counter increment.
Oct 12, 2022 05:17 AM
@Lisa_Bauer - a couple of things to note:
for (let i = 0; i < quantity-1)
should be something like this:
for (let i = 0; i < quantity-1; i++)
I can see that on the last line of the script you also have the 3 backticks, which may not be in your actual script, but are shown here, so worth checking that they are not there.
One other thing to note - your create records action - last line - works on the recordsArray, which is all good, but the action is limited to creaitng 50 records, so if you array could contain more than 50 records, you need to do something like:
while (recordsArray.length > 0) {
await table.createRecordsAsync(recordsArray.slice(0, 50));
recordsArray = recordsArray.slice(50);
}
Oct 12, 2022 06:24 AM
Thank you both for your helpful reply and assistance!
Nov 09, 2022 11:01 AM
This is excellent and very close to what I’m trying to do.
Is there a way to produce all the records at once?
let record = await input.recordAsync(‘Please select a order’, orders);
and just to get greedy: by button?
Nov 12, 2022 09:12 AM
Hi @Houston_Llew - there’s a variation on this theme higher up in the thread that I think does what you are asking for:
Is this what you mean?
Jan 06, 2023 03:18 AM
Hello all, I am looking at doing almost the same as above, however instead of "quantity", I would like it to be a linked cell with an array of data (in my case names). What would need to be changed to achieve this?
Jan 10, 2023 10:11 AM
Could you help me modify this script?