Question

I'm new using power automate.
I've seen posts to send emails to the users of a specific group in a SharePoint site. But what I need is to send an email to each user from all the groups that my site has.

I've made an HTTP request for every group in the site (I have 13 groups in my site), but my problem is that I don't know how to merge each of the JSON returned in a single array and then delete the duplicated users (because some people are in more than one group), so I can then send the emails to each one of the users in the final array.

enter image description here

Also I don't know if there is an easier method to avoid putting so many HTTP requests. As you can see in my image, my flow is already big and I don't think it would be good if it becomes bigger. Of course I won't care if nothing can be done to reduce this, as long as it works.

Thanks in advance!

Was it helpful?

Solution

Here are the steps you can try:

  1. Declare an array and initialize it with group ids like [2, 3, 4, 5]
  2. Declare a string variable to store all the emails (email1;email2;)
  3. Declare another string variable to store current email from JSON parse action
  4. Add "Apply to each" action to process group id array
  5. Within "Apply to each", add "Send an HTTP request to SharePoint" to process each group id, that is, sending id dynamically
  6. Add "Parse JSON" to parse the return users. See the schema later in my response.
  7. Add another "Apply to each" to process each user from step 6
  8. Collect user email and append it to the string variable declared in step 2 Here, you can use "contains()" function to remove duplicates
  9. Send email to the address collected in the string variable

See the screenshots below:

enter image description here enter image description here

Detail 1

enter image description here

JSON Schema (Detail 2)

{
    "type": "object",
    "properties": {
        "value": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "Email": {
                        "type": "string"
                    }
                },
                "required": [
                    "Email"
                ]
            }
        }
    }
}

Detail 3

enter image description here

OTHER TIPS

You could get all the site users with the below rest api.

/_api/web/siteusers
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top