“I created a Power Automate flow to add a new task in MS Planner whenever an email is received, however, flow is creating duplicate tasks when a response/reply is received to the same email: I would like to avoid that.”
If you use flow to create tasks from incoming emails, you probably don’t want a new task for every email. The flow should create a task only from the original email, not from each reply to that email.
But how do you tell the flow to create just a single task, without duplicates? How does it recognize when it’s a new email and when it’s a reply?
Check if task already exists
The first thing to check is if the Planner task already exists. ‘List tasks’ to get all existing tasks, and then ‘Filter array’ to filter tasks by their title. Power Automate doesn’t offer any direct tasks filter, that’s why you need two actions (unlike e.g. with SharePoint items).
Let us assume that the tasks use the email subject as their title, therefore, Title is equal to Subject.
Once you filter the tasks, you should add a ‘Condition’ to check if the filtered array is empty. Empty output from ‘Filter array’ means there isn’t any task with the title and you should add it. If it’s not empty, the task already exists and you don’t have to do anything.
You can use the length(…) expression to check if the output length (number of tasks) is greater than 0.
length(body('Filter_array'))
Don’t create a task for reply email
It gets a bit complicated with reply emails. The process above will find only exact match between the task title and the email subject. But reply emails don’t have the same subject, they’ve got ‘RE:’ or ‘Re:’ as the subject prefix. And since you don’t want ‘Task’ and ‘Re: Task’ in your tasks list, you must handle also the replies.
Add another ‘Condition’ into the ‘is empty’ branch to check if the subject starts with RE: or Re:. If it does, don’t create a new task, it’s a reply to another email. If it doesn’t, create the task.
Note: the reply prefix depends on your regional / language settings, adjust it accordingly.
Summary
Following the approach above you can avoid creation of duplicate Planner task in any Power Automate flow. In this post it was using incoming emails for the tasks, but it’ll work with any source or a template.
It’ll be actually easier with other sources. Without the replies you can rely on the unique task title and stop with the first ‘Condition’.
Hi! How can I avoid duplicate planner tasks when creating tasks from a SharePoint list?
Hello Caroline,
you can check it using the same approach: before you create a task, check if a task with the desired title already exists. Instead of email ‘Subject’ use the task title from SharePoint.
Hi, I have a few questions.
In the step “Check if task already exists” in Filter Array, I cannot find Value title. There are only Value Name, Value plan id, Value id, value item, body, value.
How can I find Value title?
Hello Wora,
I checked it and I always see all the available dynamic contents as in the article. Are you using the right action? Did you try using the value Name?
Hi Tom,
I’m looking to avoid duplication based off of parent message ID(Get message details/body/replytoID) placed in the description field of a task rather than searching the title. Is this possible with a filter array for list tasks? if there is I’m not seeing it.
people in my organization tend to follow a format; Often the trigger I have catches their keyword text, and creates the title with the text, but since it can be non-unique this may cause it to skip task creation. I could just use the parent message ID as the title, but some people are picky about change.
Actually, what I may end up doing is making the title look like a ticket and filtering the array to [title] Contains [Parent ID]. Since they don’t necessarily need to know what the numbers at the front of the task mean.
Any other elegant solutions you can think of?
Hello jo,
adding id in the task title is the best solution, I just checked the outputs from ‘List tasks’ and that’s the only property in there whose value you can control.
Your post was SOOOO helpful, thank you so much!
I’ve found a better way to avoid duplicates, and be able to add content before the subject (like a emoji if an email has been received or so…)
In the filter aray instead of using “is equal to” change it to “ends with”. This will help with RE: and re: plus will allow you to customize the tasks as long as the end remains unchanged.
Thanks again for the post!
This post was really helpful, I just have one detail since I use this flow for handover from weekday’s shifts to weekend’s shifts.
The second condition does avoid to duplicate the task if there is a prefix “RE:” on the subject, but let’s say that the first email that will add the task already comes with the prefix “RE:”?. In this case that second condition will prevent the task to be created even if the task wasn’t in the list already. I tried by changing the “equal to” for ” ends with” in the array function , but it didn’t work.
note: some emails already come with the “RE:” prefix because the task is created till one specific person is added to the email.
any tip You could give me please?
Hello Marcelo,
it’s not a perfect solution, I agree that multiple RE: are a problem, but I don’t know how to deal with that.
I have tried this but for every existing planner tasks name that does not match the email subject it creates a new task. so 400 existing task all not with a name that matches the email creates 400 new tasks with the name of the email! where have i gone wrong?