cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
scutiyog
Helper I
Helper I

Change SharePoint Group Owner with Flow

Hi,

I've got a flow that creates a security group on my site and that works fine when just setting the title of the group.  What i cannot figure out is how to change the Group Owner for that security group (since it defaults to the owner of the flow).

I have an Http request that creates the group -

flow1.JPG

This works great. 

If I add under title - "Owner":"username" or "Owner":"Another security group name" it throws an error 400 about primitiveValue nodes.

If I create the security group with just a title, parse json to get the proper id and then create a second Http request to update the owner - i still get errors about either cannot find resource or invalid request.

I  have tried using URI  _api/web/sitegroups(1085)/owner or _api/Web/SiteGroup/GetById(1090)

and the body as

{
"_metadata": (
"type":"SP.Group"
}
"SPGroup.Owner":"{'ID':'9'}"

Or 

{
"_metadata": (
"type":"SP.Group"
}
"Owner":"{'ID':'9'}"
}

i also tried using the name of the security group i want as the owner.  I've tried just putting in a single individual account name to see if i could do even that but no go.

 

I saw this thread - https://sharepoint.stackexchange.com/questions/198710/changing-the-owner-of-a-group-via-rest-api but the 1 answer it got made no sense to me as it just seemed to say what the OP already said.

 

I'm sure it's something i'm missing that maybe easy, but i'm stumped.

 

Does anyone know how you can change the group owner for a sharepoint group with Flow?

 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Brad_Groux
Community Champion
Community Champion

The SharePoint Connector for Flow has some limitations, so this is likely something you'll need to accomplish either via the SharePoint REST API, and/or via an Azure Function that utilizes the Owner property via the SP.Principal type. 

The Group Properties API reference has the Owner property listed as having a No for the Returned with a resource flag. I'm not a SharePoint developer, but from my personal experience this means that you likely can't return anything from that property via an HTTP request. 

For this reason, your best and easiest bet may be to create and call an Azure Function that runs a PowerShell script to change the group owner as desired. To get started, see the Create serverless logic with Azure Functions learning module

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

3 REPLIES 3
Brad_Groux
Community Champion
Community Champion

The SharePoint Connector for Flow has some limitations, so this is likely something you'll need to accomplish either via the SharePoint REST API, and/or via an Azure Function that utilizes the Owner property via the SP.Principal type. 

The Group Properties API reference has the Owner property listed as having a No for the Returned with a resource flag. I'm not a SharePoint developer, but from my personal experience this means that you likely can't return anything from that property via an HTTP request. 

For this reason, your best and easiest bet may be to create and call an Azure Function that runs a PowerShell script to change the group owner as desired. To get started, see the Create serverless logic with Azure Functions learning module

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

I have never worked with Azure functions - do you know of any site that might be a good start for me to test that route?

casesensitive
Regular Visitor

TL;DR can't be done with REST, but you can send some XML to a processQuery endpoint to get it done.

 

I had a long version of this typed out, but page timed out (wasn't logged in), and I lost it, so you'll have to make do with the short answer.

Almost all of the credit belongs with Chris Givens, I just tinkered with it a bit

https://social.msdn.microsoft.com/Forums/sharepoint/en-US/2dcf6e49-cff8-403b-b52e-04d240bef16d/set-g...

 

My solution is built on a series of LogicApps called by a SharePoint Designer 2013 WF with HTTP requests to keep a proper trigger on 'Create new Item' rather than faking it with a series of polls every 3/5 minutes. My way is much cheaper 🙂

  • Create Site Groups - yours is grand
  • Set Owner of new web readers and members groups to the Web Owners group, set owners group to be owned by Site Owners group
  • Create new Web, break permissions inheritance, assign RoleAssignments to the various groups

the bit you're missing goes like this:

 

XML to change owner to a GroupXML to change owner to a GroupNo errors this timeNo errors this timeSuccessSuccess

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (1,739)