Workflow dream– How to generate tasks automatically for projects?

Hello out there, I am not experienced in writing code and I am hoping that someone can help me make a workflow dream come true! I’ll do my best to explain what the goal is below, but please let me know if it is unclear.

In my Program Management base, I recently followed this example to add tasks from a Task Template table to specific projects, just copying/pasting the code: https://www.airscript.dev/2020/10/04/generating-tasks-for-projects

The code copies every task from the Task Template table into the project. What I am hoping for help with is: We have several different project types, each that involves its own set of tasks. Is there a way for me to add to the above code so that I can pick a specific set of tasks in the Task Template table, based on an identifier? Currently, to separate out which project types that tasks are associated with in the Task Template table, I have a ‘multiple select’ field that includes types like Solo Exhibition, Juried Exhibition, Traveling Exhibition, etc. I chose multiple select because there are some tasks that fall under multiple project types. Ideally, this would be the situation:

  • I can have different templates within my Task Template table , denoted with each task being assigned to a ‘Project Type’ (multiple select field because some tasks fall under multiple project types)
  • In my Projects table, when a project record is created, it is assigned to a ‘Project Type’ (single select field that contains the same options as the multiple select field options in the Task Template table)
  • When I run my scripting app, the user selects the project they wish to add tasks to, and (here is where I would like for things to go differently…)
    • The code will know which ‘project type’ the project is… let’s say that the “Super Cool Art Show” project in the Project table is a Curated Exhibition project type. Maybe the output says “you have selected Super Cool Art Show, which is a Curated Exhibition” (edit: I have figured out this part)
    • The user is then prompted to choose a task set from the Task Template table (again, need to know if obtaining a ‘set’ from within the table is possible). So the user would be able to select the “Curated Exhibition” tasks from the table so that when the app is run, Super Cool Art Show just gets those tasks that had been identified as “Curated Exhibition” tasks within the Task Template table.

I’m hoping to avoid going the way of a Zapier integration, so thank you in advance for any guidance on this!

Well, I’m going to try to be proactive (or potentially annoying) in the hope that this post doesn’t go unnoticed for months like some. @Elias_Gomez_Sainz, @W_Vann_Hall, @Justin_Barrett– you are community leaders who I have seen post about similar queries. Do any of you have any guidance you could offer on my described workflow issue re: generating different sets of tasks for different projects? Thank you in advance :pray:

Tagging @JonathanBowen, the author of the original script you linked above. He would be the ideal candidate for this task.

1 Like

Thanks @Justin_Barrett :slight_smile:

@Jessica_Pena - will post some thoughts on this later today

@Jessica_Pena - we just need to extend the model and the script to accommodate different types of project templates. There’s probably a few ways to do this, but here’s my thoughts:

Base - pretty much the same as before, but we’ve got an additional “project templates” table:

Project Templates and Task Templates are a linked pair of tables that define the project type/template and the tasks for that type:

Now what we want to do in our script is pick a project that we want to set up and the template that we want to apply to it. So our script is:

let projectsT = base.getTable('Projects');
let tasksT = base.getTable('Tasks');
let projectTemplateT = base.getTable('Project Templates');

let project = await input.recordAsync('Pick a project', projectsT);
let projectTemplate = await input.recordAsync('Pick a project template', projectTemplateT);
let projectTasks = [];
if (projectTemplate) {
  output.text(`Creating tasks for ${project.getCellValueAsString('Name')} using template ${projectTemplate.getCellValueAsString('Name')} ... please wait`);
  for (let task of projectTemplate.getCellValue('Tasks')) {
    projectTasks.push(
        {
            fields: {
                'Task': task.name,
                'Project': [ {id: project.id} ]
            }
        }
    )
  }
}
while (projectTasks.length > 0) {
    await tasksT.createRecordsAsync(projectTasks.slice(0, 50));
    projectTasks = projectTasks.slice(50);
}

The script flow is:

  1. Pick a project
  2. Pick the project type/template you want to apply
  3. Get the tasks for this template
  4. push these tasks into an array which suitable for the Tasks table
  5. create the records in the tasks table based on the data in the array

The create block creates 50 task records in one go (if there are that many) - more on this here

4 Likes

Okay, I plan on playing with this more tomorrow, but it looks like it is going to work– THANK YOU! I am so excited about how much time this is going to save our nonprofit so we can focus less on admin and more on our mission :smiley:

If I may ask another question in my pursuit to build make a magical project management base… Now that I have the Projects, Tasks, Project Templates, and Task Templates tables---- in the Task Templates table, I have a # field that notes how many days before/after an Event Date that the task should occur. In the Projects table, I have a date field that is the Event Date… my goal is that, in the Tasks table, when tasks are generated for a specific project, that the combo of Event Date (from Projects table) and Days/Before After Event that a task should occur (from Tasks Template table) will create a NEW date in the Tasks table of what day the task for that specific project should occur, so let’s say:

  • From Task Templates, the “Coordinating volunteers” should happen -30 to an event date
  • I generate tasks for our April group exhibition, which in Projects table is noted as opening April 4
  • in the Tasks table, the “Coordinating volunteers” task generates a March 4 date in a “Deadline” date field.

Can you tell me how to make this happen? :star_struck: