Aug 10, 2022 02:30 PM
Hi Airtable community!
I have a base structure where:
I’ve implemented a script so I can generate the email template tasks with the click of a button within the first projects table:
let projectsT = base.getTable('Marketing Projects');
let tasksT = base.getTable('Project & Individual Tasks');
let taskTemplateT = base.getTable('Email Task Template');
let project = await input.recordAsync('Pick a project', projectsT);
if (project) {
output.text(`You picked ${project.getCellValueAsString('Name')}`);
output.text(`Creating tasks for ${project.getCellValueAsString('Name')} ... please wait`);
let taskTemplateQ = await taskTemplateT.selectRecordsAsync();
let projectTasks = [];
for (let task of taskTemplateQ.records) {
projectTasks.push(
{
fields: {
'Name': task.name,
'Retention Channel': { name: 'Email'},
'Task Status': { name: 'Not Started'},
'Project': [ {id: project.id} ]
}
}
)
}
await tasksT.createRecordsAsync(projectTasks);
output.text('Tasks created!')
}
I’m having trouble creating another template within that third table that I can choose from when going to generate tasks via the button I have in the first table. I can’t seem to figure it out with any documentation I’ve read; is there a way to incorporate a dropdown upon running the script so that I can choose which template to trigger?
Aug 10, 2022 08:21 PM
I don’t think so I’m afraid
From what I can tell, your third table has like, different sets of email tasks, so email task 1, 2, 3 belong to Set A
, email task 4, 5, and 6 belong to Set B
?
If so I think I would end up creating a Task Template
table where the records were Set A
and Set B
etc, and link the email tasks to those
I would then use another input.recordAsync
to select the task template I needed, grab the records that are linked to the task template, and then create the records from there
As a general aside, I would highly recommend considering this comment by kuovonne about keeping the templates in the same tables as the actual data as it’s proved super helpful for my circumstances
Aug 11, 2022 06:05 PM
Not a dropdown per se, but you could use input.buttonsAsync
to display a series of buttons to the user. The button they click on would correspond to a email template that they wish to use.