cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
golfnutt82
Super User
Super User

Checking if a SharePoint User Group has already been created.

Hello,
I am able to add a new SP Group but what I need is to check to see if a group is already created before I create a new group.
The HTTP Request and JSON will error if a Group is already created.
Can I create a condition that checks if the group is already created?

golfnutt82_0-1630699723744.pnggolfnutt82_1-1630700047792.png

 

9 REPLIES 9
Expiscornovus
Super User
Super User

Hi @golfnutt82,

 

You can check if the results property is empty in the response. You can use this expression for that:

empty(outputs('Send_an_HTTP_request_to_SharePoint_Get_Site_Groups')?['body']['d']['results'])

 

conditionempty_getgroup.png

 

In the Yes branch you can add the creation of your new group. If it is false it means it has found your group.

Hello and thank you once again for your assistance.
I input the expression and renamed it to reference the name of my HTTP request action.
I received the below error.

golfnutt82_2-1631018777751.png

golfnutt82_3-1631018988673.png

 

I am sure I must be missing something

Expiscornovus
Super User
Super User

Hi @golfnutt82,

 

There might be a small typo in the expression. 

 

It is worth checking with a compose action right after the Send an HTTP request to Get SharePoint Groups 2 action.

 

When you use the expression editor and add the body field you can check if the name of the action is correct.

 

expressioneditor.png

 

 

Expiscornovus
Super User
Super User

Hi @golfnutt82,


Can you please remove the Accept application/json header entry from that request as well? I think your response will be different when you use that header. That is probably the reason why it is not receiving the 'd' property in your response.

 

clicktodeleteitem.png

 

 

The compose action seems to work fine.
Here is the output.

golfnutt82_0-1631021412911.png

 

I created a new User Group and received no issues after that change.
Going to try again using the same User Group to see if that works as expected.
I need to understand this api a lot more.
Very useful information.
Thank you very much for your assistance with this.
I will keep you posted if any issues running the duplicate group.

golfnutt82_1-1631022582558.png

 

Hello, I know the group is created at the top level but my list doesnt have any groups.
I need to add the Owners, Members and Visitors groups and then assign the users that are captured in my list item the appropriate permission.
Can I use the HTTP request to do this?

Hello,
I was able to create a group and add users to the group.
The issue now is granting permissions to the new group I created and assign unique permissions.
When I attempt to grant permissions I get an error.

golfnutt82_0-1631557695445.pnggolfnutt82_1-1631557737309.pnggolfnutt82_2-1631557959474.png

 

golfnutt82_3-1631558023400.png

Can you tell me what I am missing?
Thanks again.

Expiscornovus
Super User
Super User

Hi @golfnutt82,

 

I think there is a small typo in your Uri. It should be principalid and roledefid:

/roleassignments/addroleassignment(principalid=,roledefid=)

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (4,175)