Notifying selected tasks with a overdue task button

I’m trying to do an automation based on a button in a table of tasks. The automation side is very simple as all the conditions are put into the button. So the automations just run everyday at a certain time. So I want the button to change the status of the task to overdue if today > due date, and also if not task is not marked as completed. The modifying of status part works fine, but the notification part has some problems. It notifies me of all the tasks in the table when i run the automation, instead of the 1 or 2 that are overdue. How should i make it such that it only notifies me for those tasks that are overdue?

My formula for the overdue task button below:

if(thisRow.Status!=Completed and Today()>thisRow.[Due Date], RunActions(ModifyRows(thisRow, thisRow.Status, “Overdue”), “”), Notify(thisRow.Assignee, Concatenate("Overdue Task! - ",thisRow.Task)))

Hi again @yscias , you cannot put the runactions inside an if statement, because the “if” is static, while you want it to apply to each of your row
You need to go through each row of your task list, and check

Try something like that (Table 13 is your task table)

ForEach(
  Table13
    .Filter(
      DueDate < Today() AND Status != "Completed"
    ),
  RunActions(
    Notify(
    CurrentValue.assigne, Concatenate("Overdue :",CurrentValue.Name)
  ),
    ModifyRows(CurrentValue,Status,"Overdue"))
)

The first parameter of ForEach() define in what part of your table you want to check, here you go your filter to run only in your interesting tasks, the second parameter is the RunActions() with your both action. Then rather than using thisRow, you use CurrentValue

1 Like

So I’ve modified my formula to what you suggested, but now it just changes all my rows to Overdue. I’m really confused now… :sweat_smile:

Current formula:

ForEach(
[DB Tasks]
.Filter(
thisRow.Status != Completed and Today() > thisRow.[Due Date]
),
RunActions(
ModifyRows(CurrentValue, Status, Overdue),
Notify(
CurrentValue.Assignee,
Concatenate("Overdue Task! - ", Task)
)
)
)

In your filter you shouldn’t have « thisrow »
See my example

When using ForEach The reference is current value

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.