I have a flow that can send an email to one SharePoint Group at a time, is there a way to have it send it to them all at once. This is for a reminder email that goes out twice a month, and each of the SharePoint groups need to have it sent, I do not want to build 30 flows, I suppose i could do a Parallel branch but i still have to rinse and repeat the entire thing.
Any suggestions?
Thanks
Solved! Go to Solution.
This is how the flow should be structured if you include 'Get items' and using the output from 'Get items' in the email.
Hello @Dorinda ,
maybe you could use a loop in the flow. I don't know what your flow looks like, but if you need to repeat the same set of actions, you can initialize an array variable with the input (I guess the SP groups in your case), and use 'Apply to each' to loop through the array with the SP groups and repeat the actions for each of them.
With the flow I am using it calls it is using this in the HTTP call _api/Web/SiteGroups/GetByID(161)/users, how do i apply your idea to call each Site Group ID?
@Dorinda I think so it will work. I did not test this. Pass all group IDs in array as @tom_riha suggested. For each group ID make your HTTPS connection URI -->Parse JSON:
For each group ID it will add all emails in Group variable which you can use in email.
Please 'Thumbs Up' the posts that helped you and 'Mark as Solution' if my post answered your question.
so i have to rebuild it all over then, i am not following. Sorry
Not sure why you are thanking me, I have not solved my issue at all!!
Hello @Dorinda ,
first step is to put all the Site Group IDs into an array variable. The input must consist of opening [ , closing ] and comma separated values in quotes. You must enter all the IDs manually.
[
"GroupID1",
"GroupID2",
"GroupID3"
]
Once you have the IDs in the array, you can use 'Apply to each' to loop through that array. 'Apply to each' will take the GroupIDs from the array one by one and give you the value in the 'Current item' dynamic content. You should use the 'Current item' dynamic content as the group ID in the HTTP call.
And also the rest of the process you need to repeat for each of the groups must be inside that 'Apply to each'. Example how it'll work with the array above:
So I have not errors and it appears to be working to send emails to me but the other members of the groups didnt get anything. It is showing that it is going through the different groups, but I am the only one getting emails.
I have more groups just didnt want to run them all at once until i knew it was working.
Hi wondering if you can provide additional guidence why it is not sending emails to all of the users in the SP Group? There are three in each at the moment and I am the only one getting the emails.
Thanks in advance.
Dorinda
Hello @Dorinda ,
it's hard to tell without seeing what your flow looks like. Can you share a screenshot?
Here you go
I'd say your flow is more complicated than it needs to be, you're combining both of the approaches mentioned in this thread and I'm a bit lost in it. 🙂 I'd do it as on the screenshots below:
If you need to repeat the same process for multiple items (I see you're using 'Get items' in the flow), then the whole 'Apply to each' part on the screenshot above must be inside another 'Apply to each' where you'll process the items one by one.
I sorta started over as you instructed.
I am getting the following error
The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['properties']?['properties']?['properties']?['d']?['properties']?['properties']?['properties']?['results']' is of type 'Null'. The result must be a valid array.
this is what is in my json
{
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"d": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"results": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"items": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"__metadata": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"id": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"uri": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"Alerts": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"__deferred": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"uri": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"Groups": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"__deferred": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"uri": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"Id": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"IsHiddenInUI": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"LoginName": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"Title": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"PrincipalType": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"Email": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"IsEmailAuthenticationGuestUser": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"IsShareByEmailGuestUser": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"IsSiteAdmin": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"UserId": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"__metadata": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"NameId": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"NameIdIssuer": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"required": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"items": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
I found your blog and followed your instruction to get the JSON, however this is now the error I am getting
The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['properties']?['properties']?['properties']?['d']?['properties']?['properties']?['properties']?['results']' is of type 'Null'. The result must be a valid array.
Ok I got it fixed and it WORKED!!, my only question goes back to why I needed the Get Items, is i thought I needed that to get the items from the Calendar that is when the recurrence needs to know the dates to run. It needs to run on the 10th and the 15th of each month is there an easier way to do this?
Also I got 28 emails when i just should have gotten three so I am not sure why that happened.
I spammed my co-workers but i am so happy it is working!!
Dorinda
Something is probably looping too many times. 🙂
To run the flow only on 10th and 15th each month I'd use a trigger condition (3 dots on the action -> settings). Schedule the flow to run daily with a trigger condition that will check if the 'days' part from today's date is 10 or 15. If true, run the flow, otherwise don't do anything.
@or(equals(int(utcNow('dd')),10),equals(int(utcNow('dd')),15))
How do I find what is looping? It is built just like you showed me
Check the run history of the flow, the 'Apply to each' actions, you'll see how many times which of them did run.
The solution I shared is looping through all the SP groups in that array and sending an email to each of them. If you placed it inside another 'Apply to each' based on the 'Get items' then maybe you're getting more items from the list and repeat the email sending part more than you thought.
User | Count |
---|---|
92 | |
45 | |
21 | |
18 | |
16 |
User | Count |
---|---|
136 | |
49 | |
42 | |
36 | |
28 |