Microsoft Flow: Create a new SharePoint Group

Why?

Sometimes you just need other SharePoint Groups next to the default Owner, Visitor and Member Groups provided. So let’s use Microsoft Flow to automate the creation of new groups!

What?

This post will show how a Microsoft Flow can easily create a new SharePoint Group using the Send an HTTP request to SharePoint action. In the REST API find more information on objects like the SharePoint Group object here: https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj245927(v=office.15)

How?

My previous post https://knowhere365.space/microsoft-flow-get-the-sharepoint-guid/ would be a good start for some basics and the used variables.

1) In my scenario I had a SharePoint list that should trigger the creation of a new SharePoint Group using the ug_name column for the Group name. There is only one HTTP request needed to create a new group:

The code for the Uri:

_api/Web/SiteGroups

The code for the Body:

{
    "__metadata": {
        "type": "SP.Group"
    },
    "Title": "@{triggerBody()?['ug_name']}",
    "Description": "Automatically created through central Flow"
}

This request creates the SharePoint Group in the destination site responding with a SharePoint Group ID in the returned body. For next steps it would be wise to get that SharePoint Group ID and store it in a variable:

The code for the variable:

@{body('Send_an_HTTP_request_to_SharePoint_-_NewSPgroup')['d']['Id']}

The owner of the Flow will be the owner of the SharePoint Group… 🤔 and unfortunately setting the owner of a SharePoint Group cannot be done in this creation request and it even cannot be done using another REST API end point. Next time I will show how to change the owner of an existing SharePoint Group using Microsoft Flow 😎!

3 thoughts on “Microsoft Flow: Create a new SharePoint Group

    1. Hi Krishant,
      Glad you are here and thank you for your question!
      As far as I know, you can only add Users and Security Groups to SharePoint.
      Microsoft is looking into unifying the Office and AAD Security Groups but last time I checked this is still work in progress…

      The workaround for your scenario, could be to create a Power Automate Flow that is scheduled to check the users of the Office Group using the Office 365 Groups Connector and then for each of that user add it to the SharePoint Group?

Leave a comment