Help

Re: Workflow dream– How to generate tasks automatically for projects?

3529 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Jessica_Pena
7 - App Architect
7 - App Architect

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!

8 Replies 8
Jessica_Pena
7 - App Architect
7 - App Architect

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.

Thanks @Justin_Barrett :slightly_smiling_face:

@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:

Screenshot 2021-01-14 at 17.42.55

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

Screenshot 2021-01-14 at 17.43.02

Screenshot 2021-01-14 at 17.43.09

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

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 :grinning_face_with_big_eyes:

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:

Hi @Jessica_Pena - so the way I would do this is to have the "days before event’ field on the task template, like this:

Screenshot 2021-01-21 at 18.02.17

Then, when the script runs, we copy this value over to the tasks table - modified script here:

let projectsT = base.getTable('Projects');
let tasksT = base.getTable('Tasks');
let projectTemplateT = base.getTable('Project Templates');
let tasksTemplateT = base.getTable('Task Templates');
let tasksTemplateQ = await tasksTemplateT.selectRecordsAsync();

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 projectTask of projectTemplate.getCellValue('Tasks')) {
    let task = tasksTemplateQ.getRecord(projectTask.id);
    projectTasks.push(
        {
            fields: {
                'Task': task.name,
                'Days before event': task.getCellValue('Days before event'),
                'Project': [ {id: project.id} ]
            }
        }
    )
  }
}
while (projectTasks.length > 0) {
    await tasksT.createRecordsAsync(projectTasks.slice(0, 50));
    projectTasks = projectTasks.slice(50);
}

With the days before value in the task table and the event date on the project table, you can combine these and come up with a date when each task needs to be complete by based on the project event date:

Screenshot 2021-01-21 at 18.04.08

The “task completed by” field is:

DATEADD({Go Live Date}, {Days before event} * -1, 'days')
Dan_TL
4 - Data Explorer
4 - Data Explorer

Is there a template available? @JonathanBowen @Jessica_Pena

I took this script and tried to modify it to use for my onboarding workflow base. My tables are Onboarding, Onboarding Tasks, and Onboarding Task Template. I am getting an error at line 15. Any help would be appreciated.

ERROR

ReferenceError: OnboardingTaskTemplateQ is not defined
    at main on line 15

See modified script below:

let onboardingT = base.getTable('Onboarding');
let onboardingTasksT = base.getTable('Onboarding Tasks');
let onboardingTaskTemplateT = base.getTable('Onboarding Task template');


let onboarding = await input.recordAsync('Pick a user', onboardingT);
if (onboarding) {
output.text(`You picked ${onboarding.getCellValueAsString('Name')}`);
output.text(`Creating tasks for ${onboarding.getCellValueAsString('Name')} ... please wait`);

let onboardingTaskTemplateQ = await onboardingTaskTemplateT.selectRecordsAsync();

let onboardingTasks = [];

for (let task of OnboardingTaskTemplateQ.records) {
onboardingTasks.push(
{
fields: {
'onboardingTask': onboardingtask.name,
'Onboarding': [ {id: onboarding.id} ]
}
}
)
}

await onboardingTasksT.createRecordsAsync(onboardingTasks);

output.text('Onboarding Tasks created!')
}