Runing a script

Topic Labels: Automations
519 3
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

Hello! I would like to set up automation using "Run a script" that adds to a table new rows from a name that I give with running numbers. For example:
"Good Morning 1"
"Good Morning 2"
"Good Morning 3"......

This is the script that I use now, the output is
"Good Morning 24"
"Good Morning 25"
"Good Morning 26"......

output.text('Create Saga Tasks');
const assetBuilds = base.getTable('Asset Builds');
const sagaLanes = base.getTable('Saga Lanes');
const sagaEpisodes = base.getTable('Saga Episodes');
const tasks = base.getTable('Tasks');
const taskBundles = base.getTable('Task Bundles');
const sagaBundleTasks = await taskBundles.selectRecordsAsync({fields: [
    'Automation Type',
    'Product Default',
    'Copy Default',
    'Economy & Config Default',
const sagaBundleTask = sagaBundleTasks.records.find((record) => record.getCellValueAsString('Automation Type') === 'Saga');
if (sagaBundleTask == null) {
    throw new Error('You must have a saga task in the room bundles table');
const numEpisodes = +sagaBundleTask.getCellValueAsString('Summary').trim().split(' ')[0];
if (isNaN(numEpisodes) || numEpisodes < 1 || numEpisodes > 50) {
    throw new Error('You must have a valid number of episodes in the summary field of the saga task');
const assetBuild = await input.recordAsync('Asset Build', assetBuilds);
if (assetBuild == null) {
    throw new Error('You must select a valid asset build');
const sagaLane = await input.recordAsync('Saga & Lane', sagaLanes);
if (sagaLane == null) {
    throw new Error('You must select a valid saga & lane');
let latestEpisodeNo = sagaLane.getCellValue('Latest Episode No.');
if (isNaN(latestEpisodeNo) || latestEpisodeNo < 0 || !Number.isSafeInteger(latestEpisodeNo)) {
    latestEpisodeNo = 0;
const episodesName = await input.textAsync('Episodes Name');
const newEpisodeRecords = await sagaEpisodes.createRecordsAsync(Array.from({length: numEpisodes}, (_, i) => ({
    fields: {
        'Name': episodesName,
        'Episode': i + 1 + latestEpisodeNo,
        'Saga & Lane': [{id:}],
await tasks.createRecordsAsync(, i) => ({
    fields: {
        'Summary': `${episodesName} ${+ 1 + latestEpisodeNo}`,
        'Asset Build': [{id:}],
        'Scope': {name: sagaBundleTask.getCellValue('Scope').name},
        'Product': {name: sagaBundleTask.getCellValue('Product Default').name},
        'Assets': {name: 'Todo'},
        'Tech': {name: 'Todo'},
        'Copy': {name: sagaBundleTask.getCellValue('Copy Default').name},
        'Economy': {name: sagaBundleTask.getCellValue('Economy & Config Default').name},
        'QA': {name: 'Todo'},
        'Saga Episode': [{id: episodeId}],
        'Prevent Automation': true,

Would greatly appreciate any help

3 Replies 3

So, what is your goal?  Automation doesn't interact with user, it should be triggered by some action. Or from interface with record picker, where it can use data of a selected record.  await input.textAsync is not valid in automation script step.

There is a lot going on in this script.

Can you tell more about the source of the script? Was it written by hand or with the help of AI? 

How familiar are you with JavaScript? What is your interest level in learning more about JavaScript?

What troubleshooting steps have you taken so far?

What does your inputted data look like, including the data for the record and the data you type. 

I’m guessing that the script is mixing data types—numbers with text strings that look like numbers. 

The script also appears to be a scripting extension and will not run as an automation the way it is written. 

But honestly, from what you describe you want, I would go for a much simpler script. In fact, depending on how the data is structured, I would probably use one of my automation helper scripts to convert a number to a list to use in a repeating automation group.

I am not familiar with JavaScript, but thanks for your answer.