There are a million times I want to set a rule to change something about a project based on something that happens with a task
One example is that many of my projects have an “approve estimate” task; I’d like to be able to set up a rule so that when this task is marked complete, the project moves from a “needs estimate approval” portfolio to a “to be assigned out” portfolio
But it feels like Asana is set up so that rules triggered by task changes can only affect other tasks and subtasks, not projects
Is there a reason for this? Is there a workaround?
@Bobby_Goldstein - the workaround (for enterprise customers) would be to use a script action on a task rule. Basically, the logic would be something like:
When task marked complete → SCRIPT: call the updateProject endpoint (the script action environment has access to the task ID, project ID, and workspace ID).
Thanks! I’m pretty confident I can figure this out. But it feels a little generous to call “needing to build an solution through the API” a workaround
I’m no less curious whether there’s something built into “normal” functionality that links these extremely-dependent-on-each-other things together, and if there’s not, why on earth not?
I don’t work at Asana so can’t comment on product decisions, unfortunately. I do know that another workaround people use is roll-up fields (e.g., have a rule that sets a number field on the task when the approval task is completed, then have a rule on the portfolio that when the rollup of that number field changes, move the project).
To me, they seem like similarly involved workarounds (I use that simply to mean that they are non-obvious solves to native functionality gaps), but that one does not rely on the API and is available to all paid plans, I believe.
I don’t see any other feedback requests about this so I’ve modified your title and opened it for voting (I just voted).
I’ve been delving into this, and I’m able to set up a project rule that can change project fields based on task completion, but there seem to be limits that come close to crippling the usefulness:
I don’t see a way to specify the task that triggers the rule when it’s completed? The closest I can come is to check if the task is in a section, which means I can create a section that has just that one task in it — this works, but it’s beyond clunky
But more to the point, I’m worried that this can only be done to one project at a time? “run script” is categorized as an external action, and external actions seem to be confined to individual projects only?!
There are a few ways to do this. If you use standard task titles, you could use regex inside the script to filter for only “Approve” tasks or something. If you use native task approvals, you could filter for only those task types. You could also use a custom field and filter in the rule conditional (e.g., field called “Approval Task”, single-select with a single YES option).
Agreed that the limitations on scripts not being available in templates or bundles is frustrating (highly suggest voting for those linked threads, I certainly have). In the meantime, the workaround many people use is to have a “Script” project. Inside your project template/bundles, have a rule that when certain conditions are met (this plays best with the Approval field option from above), add that task to the script project, then run your script there. There are known limitations to this approach (e.g., the native script env will load in the script project ID instead of the originating one, so you’ll need to filter that out when you GET the task info). You’ll probably want to remove the task from the script project at the end of the script.
For “portfolio-based rules”, are you talking about rules that run on projects/sub-portfolios from within a portfolio? What’s your use case there, as the initial request seemed scoped to task rules?
There are a few ways to do this. If you use standard task titles, you could use regex inside the script to filter for only “Approve” tasks or something. If you use native task approvals, you could filter for only those task types. You could also use a custom field and filter in the rule conditional (e.g., field called “Approval Task”, single-select with a single YES option).
I think you’re saying that I could put an if statement in the code so that if certain conditions aren’t met, the script will just exit, which… that’s interesting and I might pursue this later
Agreed that the limitations on scripts not being available in templates or bundles is frustrating (highly suggest voting for those linked threads, I certainly have). In the meantime, the workaround many people use is to have a “Script” project. Inside your project template/bundles, have a rule that when certain conditions are met (this plays best with the Approval field option from above), add that task to the script project, then run your script there. There are known limitations to this approach (e.g., the native script env will load in the script project ID instead of the originating one, so you’ll need to filter that out when you GET the task info). You’ll probably want to remove the task from the script project at the end of the script.
This is driving me mad (which is not your fault!).
I could have sworn that, at the time of posting, this was impossible because there wasn’t even an option in template rules to use “run script” in the “do this” section of the rule
Now I see that there is. I realize the most likely explanation is that I was not IN “do this” when I was looking for it, but I’m finding it hard to shake the idea that it was added this morning. I will note that the ONLY external action I’m seeing as an option is “run script”
But now I’m running into a different obstacle, which is:
In the project template, I’m adding a custom script
When I create a project FROM that template, the rule is still there, but now the custom script is gone; it’s replaced with the default script that appears when I first select “run script” while building a rule
I thought I must have forgotten to add my js to the template rule, or forgot to save the change or something, but I went back and confirmed that my js is in the template rule, it just gets wiped away when I create a project from the template (!)
For “portfolio-based rules”, are you talking about rules that run on projects/sub-portfolios from within a portfolio? What’s your use case there, as the initial request seemed scoped to task rules?
I am realizing now that the use case I’d initially thought of wouldn’t really work. But what I was originally thinking was:
The only way I had of narrowing down my rule trigger to one task was to have that task in its own section
Not all of my requests require an estimate to be approved, so I’d rather not have that section appear unless my user requests an estimate be approved before starting work
The general flow is
User fills out intake form, which includes “do you need an estimate” question
A rule turns the resultant tasks into template-based project
A different rule is set up to, if user answered yes to the estimate question, add specific tasks to the project
My understanding is that the only real way to do this is, rather than adding tasks to the project, to instead add subtasks to the task before it’s converted to a project; these subtasks are elevated to tasks in the conversion
But because tasks can’t have sections, I can’t assign the subtasks to sections
So I can’t create sections nor assign those tasks to sections at the time I create the tasks
But I also have a portfolio-based rule that, if the user requested an estimate, moves the project to a different portfolio. I had the thought that I could use a portfolio-based script rule to add those sections at the same time. I now realize that won’t work because the sections have to be in place in the template for the field-changing script rule
But I expect I’ll eventually have an interest in doing something similar
Yup, basically just have the script run every time and then do nothing if conditions aren’t met. The risk you run here is if this rule runs a lot, you might hit rate limits…
Yeah so you can add the script module to a rule in a template but…as you’ve discovered, when you instantiate the template, it clears the rule out (without notifying you). The workaround I was trying to describe is that in your template (or bundle), you have a rule that just adds the task to a dedicated Scripts project (you can add it to a section of that project for this specific script, use a custom field, etc.). Then, in that Scripts project, you have a rule that triggers when a task is added (to a section, with a field set, etc.), runs your script, and then removes the task from that Scripts project. It’s basically centralizing all of your scripting (it’s definitely a workaround and not idea at scale, but it does fundamentally work).
From your description, maybe having two separate templates (one for no estimate, one for w/ estimate) and then routing different intake tasks to each template would be a better solution. You’d then dump all the projects into one portfolio there and (assuming your estimate question on the form is mapped to a field which should get pulled through to the project when converted), you’d have a portfolio rule that adds projects to separate estimate/no estimate portfolios.
My organisation uses portfolios to organise our projects.
As a marketing department, we each have different portfolios we use based on areas of speciality, e.g. email marketing portfolio, social media portfolio. However, we do have. projects that we work on as a team as they require input from all departments.
We would like the ability to have a project added to different portfolios based on an action. For example, a project for a campaign that is in the email marketing portfolio has a task underneath it that is assigned to a social media person (so 2 departments are working on project), then the project gets automatically added to the social media portfolio too.
It would be great if project template rules could trigger portfolio actions. Currently, there is a disconnect between tasks inside a project and the portfolios.
Example:
Trigger: Task or Milestone is marked complete
Action: Update a custom field in the portfolio
This would keep portfolio view accurate without manual updates
I’ve merged your post into an existing topic where you can click the title to scroll to the top and vote by clicking the Vote button. Existing votes will be merged.