Wednesday, April 8, 2020

Microsoft Flows: Send an email to Sharepoint Group

Microsoft Flows doesn't have direct access to Sharepoint Groups. So, we need to use Rest API to fetch group members from a sharepoint group. Also, to send an email, we need Email IDs, thus we extract email ids of all group members from the Rest Response and use them in Email Notification.

Below are the step by step procedure to achieve it .


  1. Use Send an HTTP Request to Sharepoint action to call below Rest API to fetch group members
    /_api/web/sitegroups/getbyname('<<GroupName>>')/users?$select=email&$filter=PrincipalType%20eq%201

    Here we are selecting only email as we don't need other information. Also, we filtered for PrincipalType to 1 so that we want only Users from the Group. If we want other types, we can update the filter. 

  2. As the response from HTTP request is in JSON (default), we need to use Parse JSON action to parse the response. 


    The content for this action is output of HTTP call and for Schema, we can click on Generate from Sample and  paste the RAW response from HTTP action to it.

  3. Now we have the response with List of Users in Object Collection, we need to extract EMails from it.  We can use Apply to Each action, but we will go with better performance actions - Select and Join as discussed in earlier post

    Select action is to Extract only Emails for the Object collection and convert to simply array of Emails.
    Join action is to join the Emails in array with semi-column delimiter

  4. Now we have all the Email ids in output of Join action and we can use it in Email Notification.

Happy coding :-)

No comments:

Post a Comment