"not" operator for conditions in rule

I hope Asana supports the “not” operator for conditions in rules.

In the early stage, not all conditions are available for scenarios.
If we have the “not” operator, we can cover a wider range of situations for automation.

For example, I want to change a task status to “undone” when the task status changes to “complete” if all subtasks are not done.
Currently, we only have a condition for “all subtasks are done”. So we cannot create the right condition for that.

2 Likes

Yesterday they released an “otherwise” branch in Rules, did you see? :slight_smile:
that’s basically what you need, make a branch with the right condition that does nothing (like multi-home in a dummy project of whatever) and then an Otherwise branch.

Thank you for your comment.
I tried the rule below.

Unfortunately, it didn’t work well when a task has no subtask. The task status changed to “incomplete”. In this case, I need another condition for “at least one subtask is incomplete” or “task has no subtask” to achieve what I want.

Finally, I assume the following:
Even if I use the “not” operator, the rule doesn’t work well when “All subtasks are marked as *” doesn’t represent “A task has subtask/subtasks and All subtasks are marked as *”. So, my post might not be a good proposal.

Does someone have a solution for this specific case?

Indeed there would be a missing use case for you here

1 Like

I made up with a workaround. But it is complicated.

1 Like

@Tetsuo_Kawakami,

This looks great, but I’m pretty sure that you’ve left out a screenshot for the rule that sets custom field 2 (state of subtask(s) completion).

Thanks,

Larry

@lpb
Thanks for your comment.
For subtask(s), custom field2 is dummy.
In this case, only custom field2 for parent task(s) is important because rule3 runs on tasks (parent tasks). And the rollup function sets the state of subtask(s) for parent tasks automatically.

1 Like

Eventually I noticed that rule1 and rule2 can be combined into one like below,

1 Like

Whoops; I hadn’t realized custom field 2 was a rollup.

Very clever, @Tetsuo_Kawakami! I’ve had a need for this before and I’m sure it will come up again and will use your solution!

1 Like

In good point of rollup(), it calculates just a value of subtask(s).
When I read the document of it, I strongly felt weird.
‘Why ? it doesn’t calculate values including parent task!’

at the end of the day, asana is correct!

1 Like

I’m missing this feature today.

It would have solved: Check if: not(All subtasks are marked as Complete)

Now I need to choose between All subtasks are marked as Complete and All subtasks are marked as Incomplete.

There may be a workaround possible but it is far from intuitive.

Being able to wrap a condition (or a set of conditions) to an inverse would solve this and many other use cases where the specific variations of the condition options don’t include the exact option I am looking for.

2 Likes

Hello All,

I did a bit of searching but I wasn’t able to find a topic about this particular workflow nuance.

In my project rules move task from section to section adding new subtasks to the task in each section.

There is the ability to check if all subtasks are complete. And I can check is all subtasks are incomplete.

I have to rule to mark the task incomplete and comment a reminder to the user to complete all subtasks before completing the parent task. This works great is all the subtasks are incomplete but does nothing is some subtasks are incomplete.

The other rule to move the task to the next section also hangs because the condition of all subtasks being complete is not met.

I’m unable to use any third party extensions so has anyone found a native workaround? Or am I just being dense and missing something obvious?

Welcome back @Michael_Mulick :slight_smile:

I’m merging this post into feedback that would solve this.

@Tetsuo_Kawakami Most straightforward workaround I think is this:

@Jan-Rienk
thanks for your comment.
It works well when a task has subtask(s).But It doesn’t work well when a task doesn’t have subtask(s).:sob:

P.S.
Now a day, we can also use script action to solve this if we have enterprise/+.
A code is the following.(I used AI for coding.)

/**
* What's in scope?
* 1. (string) project_gid, workspace_gid, task_gid (only if triggered on a task)
* 2. (function) log - this behaves like console.log and takes any number of parameters
* 3. (object) *ApiInstance - for each group of APIs, an object containing functions to call the APIs; for example:
*    tasksApiInstance.getTask(...)
*    goalsApiInstance.addFollowers(...)

* For more info, see https://github.com/Asana/node-asana
*/

async function run() {
  // サブタスクを取得
  const subtasks = await tasksApiInstance.getSubtasksForTask(task_gid);
  // サブタスクの完了状態を確認
  let allSubtasksCompleted = true;
  for (const subtask of subtasks.data) {
    // サブタスクの詳細情報を取得
    const subtaskDetails = await tasksApiInstance.getTask(subtask.gid);
    // 未完了のサブタスクがあるかチェック
    log(subtaskDetails.data.completed)
    if (!subtaskDetails.data.completed) {
      allSubtasksCompleted = false;
      break;
    }
  }
  
  // 未完了のサブタスクがある場合、親タスクを未完了に設定
  if (!allSubtasksCompleted) {
    let body = {
      "data":{
        "completed": false
      }
    }
    await tasksApiInstance.updateTask(body, task_gid);
  }
}

// To function properly, the script must end with returning a Promise via run().
run();

In that case a not operator or function alone wouldn’t solve the challenge. To solve this without scripting it would also require a “has subtasks” condition. For which it would probably also be handy to invert with a not(has_subtasks).

1 Like