I'm working on a Power Automate flow where the flow is supposed to connect to Planner, get the tasks which are due tomorrow and send a message to an MS Teams Channel.
I got the entire flow working but with my current implementation there's 1 MS Teams Channel message per each task. What I'm trying to do is - every day send only 1 message to the given channel which contains the information about all of the tasks which are due tomorrow.
Here's my current flow:
You can see the flow image here (Stack Overflow has upload problems currently): https://i.ibb.co/xmXZQVr/upload.jpg
Currently I'm taking only the first Assignee ID and getting the name, but I'd also like to get the names of all of the assignees and join them with a comma. I understand there is going to be a "Apply to Each" action, but not sure how to join the data of them and use in the Send to Teams Channel action.
I would be very grateful if anybody could give some hints on what changes should be done in my current flow to:
Thanks!
I would use a select to retrieve the UserId of each assigned user and loop through that array. The result of the get user profile can be appended to a temporary array variable. After that you can join it back together as a comma separated string.
Below is an example
I would start by using to temp Array variables (OverdueTaskArray and AssignedToUserArray)
In this setup I filtered the lists tasks by using an expression in a Filter Array action. In the where I used the following expression
@and(equals(empty(item()?['dueDateTime']), false), equals(formatdatetime(item()?['dueDateTime'], 'yyyy-MM-dd'), addDays(utcNow(), 1, 'yyyy-MM-dd')))
In the Apply to each the Body of the Filter Array is used.
With a Select the list of Assigned users is retrieved
In a second nested apply to each we loop through the items of that Select outputs.
Per item the profile is retrieved and the mail property is appended to the AssignedToUserArray
Per task the Created By User is retrieved
The task title, Created By User Display Name, and the AssignedToUserArray items joined with a comma are appended to the OverdueTaskArray variable
The AssignedToUserArray variable is reset to null for the next loop.
The OverdueTaskArray is used in a Create HTML table action
The output of that Create HTML table action is used in the Teams Post a message action.