I'm definitely new to Flow, but I looked around and haven't seen this yet.
I'd like to generate a Task in Microsoft Planner based on emails that come in. That part is fairly straightforward. The issue I'm bumping up against is discovering if a task already exists.
I'd like to look through my tasks and check the title (or body) for the "Conversation Id" of the email. If a task with that Conversation Id doesn't exist, then I'd like to create a new one. If such a task DOES exist, I'd like to append the new email text to the Task Description (or maybe add a new comment).
If it comes right down to it, my issue is checking a container for a matching item. I'm just struggling with the "conditions" and "apply to each" (couldn't we just have a "get a match" for different container types?) flow items.
Do you want to use Conversation Id as a basis for judging whether a task exists?
Then I think you need to use Conversation Id as part of the task title, or as a title.
I did a test on my side, please take a try with the following workaround:
Use the list tasks to get all the tasks, then configure Condition to determine if the task already exists. It is based on whether the title contains Conversation Id.
If it is included, first use Html to text to get the content of the email body, then use Get task details to get the description of the task, and configure the output corresponding to the above action in the description field.
If it does not, create a new task with the title containing Conversation Id.
Please take a try.
Thank you! That's exactly what I needed! I was getting closer to this with trial and error, but your example is exactly what I needed!
As far as Conversation Id, I wasn't sure if that was the title of the email, or a unique, underlying identifier. I wasn't sure whether it would be small (and could be put in the Task Title) or large (and should be included in the Task Description).
Thanks again, for your help!
Sorry, there is still a problem with the design of this Flow. I found that there is a problem with the logic for judging whether the planner already exists later.
If this is configured, it will create a lot of duplicate tasks.
I have improved on the basis of the previous, as below:
Please take a try again and feel free let me know if you have any question.
Yeah, I noticed that issue. I was trying a bunch of idifferent variable manipulations (which I obviously don't quite understand), but was never quite able to eliminate the duplicates - this was mainly because I had trouble updating details immediately after creating the task (it couldn't find the task 1 step after it was created).
Your solution has not revealed a critical step: what is your "condition" at the bottom of the first picture?
And if you can share it, would you mind explaining, in detail, what is happening with your Select and your condition?
(I feel like I can read it, but I haven't been able to come up with the working arrangement yet, so obviously I'm missing a detail or two.)
The Title probably isn't a great place for the Convo Id: it's a rather long string, and Title is a rather short string.
My mistakes, the screenshots do not seem to be fully presented. I made a change to the location of Conversation Id. If you don't configure it in the Title, you could put it in Description.
It was also made some changes on the basis of the original.
Adding a step is to get the existing Task Description, save it in a String variable, and then determine whether the String contains Conversation Id that in the mail.
If it contains, update Description; if it does not, create a new Task, now you could configure the content you want to configure in Title, followed by update Description, you need to configure the Conversation Id.
The only thing that is unsatisfactory is that if Conversation Id is configured in Description, the execution time of Flow will be longer. Because Description cannot be obtained directly through List tasks.
Save all Task Description:
Determine if the Task already exists:
Please take a try again.
Thanks again for all your help - it definitely looks like we're getting closer!
Your example definitely seems to cover some new ground for me, but I think I need to create an array that extracts the Task Id, with the Description. Right now (if I'm reading it correctly), you should be updating the last task added to your AllTaskDescription string - not the task that correlates with the conversation Id. Unfortunately, I haven't figured out how to lookup a Task by TaskId...
I attempted to use this solution for a similar problem I was having. For each existing task that does not match the conversation id a new task is created. This logically makes sense but it is not ideal. I would like for only 1 task to be created if all existing task titles do not contain the conversation id.
Thanks in advance!
Really good explanation, a question is there in any way possible to limit the number of tasks which are retrieved from Planner?
We have alot of tasks in our planner which are done.
@v-bacao-msft thanks for this, it's providing us with a pretty reasonable ticketing system via. Planner in Teams which is great!
For some reason it appears to be running the flow on every ticket in the plan, so in my case creating 65 new tasks (we're using an existing plan with tasks on for testing purposes).
After running a second time, it updated 1 task, then created 64 new ones, so the create / update functions are working.
I think I need to filter the array produced with the data operation somehow, which I think is what you posted in your second update, but after trying that I'm still getting the same result.
I was able to make it work by Initializing a variable of the Title of the tasks
1- verify if the Subject is in the Value of Tasks if not create a new one if so
2- set the variable ok the Title and validate if the Title match the Subject
my approach to solve the issue in three steps:
- CreateTitle: Create a unique title to identify individual tasks
- SearchTask: Filter Array of Tasks based on unique title (Title eq outputs('CreateTitle')
- CountTasks: Count matching tasks… length(body('SearchTask'))
... shoud be 0 (does not exist) or >0 (minumum of 1 task exist... you may decide further steps with duplicate tasks)
The solution is to loop through tasks. First, initialise a boolean variable (fCreateNew) as true. Then loop through each existing task. If the task exists (and is not completed), update it and set fCreateNew to false. At the end, if fCreateNew is still true, create the new task.
(Other solutions create a task for each task that doesn't match the description, so be careful implementing them! I had a hard time deleting all the created tasks!)
In my example here, I am create a new task based on an email arriving to a shared folder:
Here is the new boolean variable:
This part will update any task that matches the description AND is not yet complete
The variable above is set as follows:
After every task has been looped through, if fCreateNew is still true, then a new task can be created as follows:
Hope this helps!
The solution of @ghazi works perfect for me!
the only problem I'm running into now is that I can't refer a task to a person.
Does anyone have a genius solution to solve this?
Check out the new Process Advisor community forum board!
Check out new user group experience and if you are a leader please create your group
Participate in the Power Virtual Agents Community Challenge
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.