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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,609)