Sync SPO Group Users To SPO Lists Using MSFlow

Microsoft Flow is a SaaS-based platform that allows power users to send an email to a group of users. MS Flow doesn't support sending a direct email to SPO Group. Let's have a look at the scenario and solution to get started.

Scenario

If we need to send an email to SP Groups using MS Flow, it doesn’t support sending emails to SPO Groups. To make it work, a developer needs to store all the users as list items because an SPO List item can be used as “To” to send an email.

Start with the solution

Create a list with key & value pair as string type. Add Key as Group Name and MS Flow will add the users as the values against the defined key.

MS Flow at a glance

MS Flow is a scheduling activity that can be defined periodically as per the requirement, i.e., hourly, daily, weekly, monthly etc.

Sync SPO Group Users to SPO Lists using MSFlow 

Let's start step by step.

Step 1

Recurrence is added as a trigger point to this flow. It can be defined as per the requirement and it works like a scheduled job.
 
Sync SPO Group Users to SPO Lists using MSFlow 

Step 2

Initialize a variable, it will be used to store all email addresses with defined delimiter separator.
 
Sync SPO Group Users to SPO Lists using MSFlow 

Variable name SPOGroupMembers of string type.

Step 3

Get Item from the list named GroupUsers. This list has two columns, consisting of a “Single Line Of Text”.
 
Sync SPO Group Users to SPO Lists using MSFlow 

Step 4

Apply for each loop. The list can have multiple keys.

Add an action “Send an HTTP request to SharePoint”. Three properties are important for this action.

  1. Site Address - It should be the URL of the site collection.
  2. Method - Get request.
  3. URL - “_api/Web/SiteGroups/getbyName(“Column Name”)/users?$select=Email

    Sync SPO Group Users to SPO Lists using MSFlow

Step 5

Add the action Parse JSON. It expects the payload from the above request. To get the payload or JSON, the response can be obtained from the below article.

Take out the payload from the HTTP request and paste it into the Schema section.

Sync SPO Group Users to SPO Lists using MSFlow 

Step 6

Get the result after parsing the JSON. Loop through the result and store it into the above-created variable, i.e., SPOGroupMemebers with “;” as delimeter.
 
Sync SPO Group Users to SPO Lists using MSFlow 

Step 7

Update the SPO List Item with SPOGroupMemebers Variable.
 
Sync SPO Group Users to SPO Lists using MSFlow 

Output

SPO Group has two users -

Sync SPO Group Users to SPO Lists using MSFlow

SPList after running the flow will look like below.

Sync SPO Group Users to SPO Lists using MSFlow 
Happy Coding.