Hi
I am creating a flow to get all the item assined to a single user and send an email to that user with all the item detail .
I dont want to send separate email for each task .
Could you please help me with any option .
Thanks
Gautmish
Solved! Go to Solution.
Hi @gautmish,
Could you please share a bit more about your SharePoint task list?
I have created a SharePoint task list on my side and the data structure of it as below:
I have made a test on my side and please take a try with the following workaround:
first(item()?['AssignedTo'])?['Email']
union(variables('AssignedToEmailArray'),variables('AssignedToEmailArray'))
@empty(variables('AssignedToEmailArray'))
Within "Do Until" action, add a "Get items 2" action, specify Site Address and List Name (Type Task list name as a custom value).
Add a "Filter array" action, From set to value dynamic content of the "Get items 2" action. Click "Edit in advanced mode", type the following formula:
@equals(first(item()?['AssignedTo'])?['Email'], first(variables('AssignedToEmailArray')))
Add a "Select" action, From set to output of the "Filter array" action. Within Map entry, type 5 enties.
The corresponding value of Task Name read as below:
item()?['Title']
The corresponding value of Start Date read as below:
item()?['StartDate']
The corresponding value of End Date read as below:
item()?['DueDate']
The corresponding value of Task Status read as below:
item()?['Status']
The corresponding value of Description read as below:
item()?['Body']
Note: Please make sure these columns (Title, Start Date, Due Date, Status, Description) that you want to show up within HTML table contain values.
Add a "Create HTMl table" action, From set to output of the "Select" action, Include Headers set to yes. Then add a "Send an email" action, To field set to following formula:
first(variables('AssignedToEmailArray'))
Body field set to output of the "Create HTML table" action, Is HTML field set to Yes.
Add a "Compose 2" action, Inputs set to following formula:
skip(variables('AssignedToEmailArray'),1)
Add a "Set variable" action, Name choose AssignedToEmailArray, Value set to output of the "Compose 2" action.
Image reference:
The flow works successfully as below:
Best regards,
Kris
Assigned items are stored in sharepoint list .
we have a sharepoint task list where we have created few tasks for different users . One user may have multiple task . So we want to send email to one mail to each user with their task details .
Thanks
Gautmish
Hi @gautmish,
Could you please share a bit more about your SharePoint task list?
I have created a SharePoint task list on my side and the data structure of it as below:
I have made a test on my side and please take a try with the following workaround:
first(item()?['AssignedTo'])?['Email']
union(variables('AssignedToEmailArray'),variables('AssignedToEmailArray'))
@empty(variables('AssignedToEmailArray'))
Within "Do Until" action, add a "Get items 2" action, specify Site Address and List Name (Type Task list name as a custom value).
Add a "Filter array" action, From set to value dynamic content of the "Get items 2" action. Click "Edit in advanced mode", type the following formula:
@equals(first(item()?['AssignedTo'])?['Email'], first(variables('AssignedToEmailArray')))
Add a "Select" action, From set to output of the "Filter array" action. Within Map entry, type 5 enties.
The corresponding value of Task Name read as below:
item()?['Title']
The corresponding value of Start Date read as below:
item()?['StartDate']
The corresponding value of End Date read as below:
item()?['DueDate']
The corresponding value of Task Status read as below:
item()?['Status']
The corresponding value of Description read as below:
item()?['Body']
Note: Please make sure these columns (Title, Start Date, Due Date, Status, Description) that you want to show up within HTML table contain values.
Add a "Create HTMl table" action, From set to output of the "Select" action, Include Headers set to yes. Then add a "Send an email" action, To field set to following formula:
first(variables('AssignedToEmailArray'))
Body field set to output of the "Create HTML table" action, Is HTML field set to Yes.
Add a "Compose 2" action, Inputs set to following formula:
skip(variables('AssignedToEmailArray'),1)
Add a "Set variable" action, Name choose AssignedToEmailArray, Value set to output of the "Compose 2" action.
Image reference:
The flow works successfully as below:
Best regards,
Kris
Thanks for this walk through. I am getting an error on the formula:
first(item()?['AssignedTo'])?['Email']
'first' expects its parameter be an array or a string.
Any ideas what might be causing this?
Thanks
Hi @Bill_Hand
Could you please confirm if you are using Task list or normal list with Assigned to coulmn .
please try below options and let me know if it helps.
1. Assigned to coulmn should be User only field not User and Group
2. Dont use the same array to make it distinct , create a diffrenet distinct array and use it .
3. Check the output of Assigned to array if it consists of data
4. Assigned to coulmn should not be null
Thanks
Gautmish
Hi @v-xida-msft
Many thanks for this solution. I have an issue, flow is sending one email per task - so if I have 4 tasks per user, I receive 4 emails with html table. Where can be an error? I've checked it and seemens everything is as descirbed here.
Best regards
Hi, anyone using this kind of flow and have some issues? I still can't manage to solve it 😕
@fzer0 - I too am having the issue where I am getting an email for each task in the task list.
@v-xida-msft - Do you know what is causing this to send an email for each task?
It seems to be the Do-Until is not working with the AssignedToEmailArray variable after the compose performs the union.
The apply to each is creating an array of my email address 3 times for each task in the task list. The flow moves on to the compose step and the output from that is only 1 email address as is expected. However the Do-Until is running 3 times one for each time my email was assigned to a task.
Formula from Compose before the Do-Until
union(variables('AssignedToEmailArray'),variables('AssignedToEmailArray'))
Do Until formula
@empty(variables('AssignedToEmailArray'))
Let me know if you need any more information to help troubleshoot this issue.
Thanks,
Zach
@fzer0 - I was able to fix the issue for myself please try the below changes and see if they work for you.
I removed the first Compose and created an Initalize Variable 2 in its place. Configure this variable as below:
Name: DistinctEmailArray
Type: Array
Value: set to the below formula
union(variables('AssignedToEmailArray'),variables('AssignedToEmailArray'))
You will need to update the following fields to reference the new array.
Hi All,
I still have an error on apply to each below
Value on Appent to array variable:
Can you provide a screenshot of the error and possible a litle more in the way of a screen shot of your Flow?
Scott
Hi Scott,
Any advice
thanks
Hi @Codered
I have attached some screenshots of my flow to hopefully help you out with yours.
Formula value for 'Append to Array Variable'
first(item()?['AssignedTo'])?['Email']
Init Variable 2 Formula
union(variables('EmailArray'),variables('EmailArray'))
Filter Array Formulas
first(item()?['AssignedTo'])?['Email']
is equal to
first(variables('Email'))
Skip Formula
skip(variables('Email'),1)
Output is the output from Compose 2
Your array or variable names may be different than mine but this is the general setup.
Let me know if you need anymore help
Hi Scott,
I think something wrong with my "Append to Array Variable" , when i added it have an error.
Thank you
In you Initalize Variable after you get your SharePoint items is that set to 'Array'? The error you are receiving makes it seem like it might be set to 'Object'.
User | Count |
---|---|
16 | |
16 | |
14 | |
9 | |
8 |
User | Count |
---|---|
27 | |
26 | |
24 | |
23 | |
14 |