cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hemant_srk
New Member

Item level permission using flow to group

How to give contribute permission to Group1 on list item Item1? details as follows. Unique permission are set on Item1.

List: Test

Item: Item1

Group: Group1

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @Hemant_srk,

 

What kind of group are using. Microsoft 365, SharePoint Group or a Azure AD Security Group?

 

Adding an existing group should be possible by using the addroleassignment method from the SharePoint REST API.

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/set-custom-permissions-on-a-list-by-using...

 

You can refer to the principalid and set a specific role, like contribute permissions and use in an Send an HTTP request to SharePoint action.

 

Below is an example of that:

I have used two variables in my example. The Group ID contains the principalid, which is a number like 13. The ListTitle variable contains the title, which in your case is Test. In the Items(x) I have referred to the specific itemid. In this example I used a list item with id 1.

 

 

_api/web/lists/getbytitle('@{variables('ListTitle')}')/items(1)/roleassignments/addroleassignment(principalid=@{variables('GroupID')},roledefid=1073741827)

 

setitempermissions.png

 

View solution in original post

3 REPLIES 3
Expiscornovus
Super User
Super User

Hi @Hemant_srk,

 

What kind of group are using. Microsoft 365, SharePoint Group or a Azure AD Security Group?

 

Adding an existing group should be possible by using the addroleassignment method from the SharePoint REST API.

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/set-custom-permissions-on-a-list-by-using...

 

You can refer to the principalid and set a specific role, like contribute permissions and use in an Send an HTTP request to SharePoint action.

 

Below is an example of that:

I have used two variables in my example. The Group ID contains the principalid, which is a number like 13. The ListTitle variable contains the title, which in your case is Test. In the Items(x) I have referred to the specific itemid. In this example I used a list item with id 1.

 

 

_api/web/lists/getbytitle('@{variables('ListTitle')}')/items(1)/roleassignments/addroleassignment(principalid=@{variables('GroupID')},roledefid=1073741827)

 

setitempermissions.png

 

Hemant_srk
New Member

Group: Group1 is SharePoint group

 

Is there any way initialize variables based on Item's Site Address and List title instead of typing? means

Initialize variable - listTitle = Current item's Parent Title (List Title)

Initialize variable - SiteAddress = Current item's Parent Site URL(Site Address)

Expiscornovus
Super User
Super User

Hi @Hemant_srk,

 

You could use the input parameters of one of your actions (like the When an item is created) action for that. Those values can be collected via expressions.

 

One challenge will be that you can't directly get the list title from those parameters, you will get the GUID of the list.

 

So, in that scenario you would have to retrieve the list name via a separate request or use the api/web/lists(guid'yourguid') method instead of the api/web/lists/getbytitle('listtitle') in your Send an HTTP request to SharePoint action.

 

The expression for the list would be (when using a When an item is created trigger action):

trigger()?['inputs']['parameters']['table']

 

For the site address that would be:

trigger()?['inputs']['parameters']['dataset']

 

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.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,779)