Hello! I am new to Airtable and scripting. I have a list of speakers which is populated from a speaker intake form and I have a list of dates/times (every Thursday at Noon). In the Scheduled table I manually assign a Speaker to a date. When I do this, I want to automatically create a new record in the Creative Log table, so our designer knows to create new graphics for that episode.
I also want the due date to be set 2 weeks before scheduled date.
This is what I have so far and need help.
Thank you!
`// pick tables from your base here
let tasks = base.getTable(‘Creative Log’);
let projects = base.getTable(‘Speakers’);
let view = table.getView(“Scheduled Speakers”);
output.inspect(view);
// prompt the user to pick a template for our project
output.markdown(’New Episode’);
let name = await input.textAsync(‘Creative Log’);
// create the project - change the field name to one in your base
let projectId = await projects.createRecordAsync({
‘Episode Cards’: name,
});
// collaborator
let collaboratorIdByName = {Jorge Raphael};
for (let collaborator of base.activeCollaborators) {
collaboratorIdByName[collaborator.name] = collaborator.id;
}
// create the tasks - change the field names to ones from your base.
// the [{id: projectId}] links the newly created records back to our project
await tasks.createRecordsAsync([
{
fields: {
‘Job request’: ‘Episode Cards’,
‘Speaker’: [{id: projectId}],
‘Status’: [Need to start],
‘Type of asset’: [Social Media],
‘Priority’: [Important],
‘Due Date’: [2 weeks before scheduled date]
’Assigned To’: {id: collaboratorIdByName[Jorge Raphael]},
},
},
])