
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 06, 2022 10:13 AM
Hello Community!
I have the below script that will create X number of records based on the Episode Count, but I would like to tweak it to auto-number those episodes each time. For instance, Show 1 has 5 episodes, then each episode record would be numbered 1, 2, 3, 4, 5
//Tables
let projects = base.getTable('Shows');
let episodes = base.getTable('Episodes');
//Record Input
let record = await input.recordAsync('Please select a project', projects);
//Record variables
let quantity = record.getCellValue('Ep Count');
let order = record.id;
//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: {
'Shows': [{id: order}],
}
});
}
//Create new records
await episodes.createRecordsAsync(recArray);
}
Any insight would be so incredible appreciated :pray: Thank you!
Solved! Go to Solution.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 06, 2022 10:24 AM
Sounds like your Episodes table should have a Number field.
recArray.push({
fields: {
'Shows': [{id: order}],
'Episode Number': i + 1
}
});
its i + 1
and not just i
because your loop starts i
at zero, and I’m assuming you don’t want “Episode 0” to be a result.
Also FYI your script will throw an error if you ever try creating more than 50 episodes at once.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 06, 2022 10:24 AM
Sounds like your Episodes table should have a Number field.
recArray.push({
fields: {
'Shows': [{id: order}],
'Episode Number': i + 1
}
});
its i + 1
and not just i
because your loop starts i
at zero, and I’m assuming you don’t want “Episode 0” to be a result.
Also FYI your script will throw an error if you ever try creating more than 50 episodes at once.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 06, 2022 11:04 AM
Kamille - you are amazing!
This worked perfectly. Thank you so much for the assist here!
