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 😎!
Thanks very much for the post Django! I had a question. Do you know if its possible to use Power Automate to add an Office 365 (Microsoft 365) group to a SharePoint group?
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?