Microsoft Flow: Change a SharePoint Group owner

Why?

Setting (or changing) the owner of an existing SharePoint Group could be something you want to do in bulk or to automate immediately after an automated creation.

What?

This post will show how a Microsoft Flow can update the SharePoint Group owner to another SharePoint Group using the Send an HTTP request to SharePoint action. Most of the credits need to be given to Jason Lee because of his explanation here 👍.

How?

The post https://knowhere365.space/microsoft-flow-create-a-new-sharepoint-group/ showed how to create a new SharePoint Group and is a must-read to fully understand what you will be doing here. Another thing to be aware of, is that each User and each SharePoint Group gets a unique ID within every specific SharePoint Site Collection once they are “ensured” (=used in any kind of way like a people picker, access share, group membership etc).

1) First you need to get:

  • the ID / GUID of the SharePoint Site Collection
    (variable = varSiteGUID)
  • the ID of the SharePoint Group you want to change the owner of
    (variable = varNewGroupId)
  • the ID of the SharePoint Group that will be owning this SharePoint Group
    (variable = varNewGroupOwnerId)

See the post https://knowhere365.space/microsoft-flow-get-the-sharepoint-guid/ on how to get these ID’s in a Microsoft Flow. Once you have these ID’s you need to use them in an special kind of HTTP request with an XML Header:

Code of the Uri:

/_vti_bin/client.svc/ProcessQuery

Code of the Headers:

{
  "Content-Type": "text/xml"
}

Code of the Body:

<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="15.0.0.0" ApplicationName=".NET Library" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
  <Actions>
    <SetProperty Id="1" ObjectPathId="2" Name="Owner">
      <Parameter ObjectPathId="3" />
    </SetProperty>
    <Method Name="Update" Id="4" ObjectPathId="2" />
  </Actions>
  <ObjectPaths>
    <Identity Id="2" Name="740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:@{variables('varSiteGUID')}:g:@{variables('varNewGroupId')}" />
    <Identity Id="3" Name="740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:@{variables('varSiteGUID')}:g:@{variables('varNewGroupOwnerId')}" />
  </ObjectPaths>
</Request>

Leave a comment