cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Resolver II
Resolver II

Change Permissions for SharePoint List item on New and Edit

Combining the steps from  https://www.portiva.nl/nl/portiblog/2019/10/21/set-list-item-level-permissions-in-sharepoint-using-f... and https://collab365.community/manage-permissions-sharepoint-list-item-using-microsoft-flow-add-contrib... I've have successfully broken permissions on a new item and set them as Read only for the creator and given edit rights to a SharePoint group.

But, we have a scenario where someone in the SharePoint group may need to "Reject" the item which will send an email to the user to make changes.
I was successful in writing the flow to add the "Contribute" rights back to the creator at that point.
But the "Clear Permission" step doesn't seem to work after the first run as now the user gets a permission setting of "Contribute, Read".
And once they resubmit the item, the automation doesn't reset them back to "Read Only". The Automation shows the clear permission step as running successfully, but it doesn't actually clear the permissions on an edit.

Anyone else ran into this scenario and know a fix.. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver II
Resolver II

Re: Change Permissions for SharePoint List item on New and Edit

To get this to work for New Items, as well as after editing items I ended up with two Automation's. 

First Automation,  which runs on created items, first cleared permissions using: _api/lists/getByTitle('Listname')/items(ID)/breakroleinheritance(copyRoleAssignments=false,clearSubscopes=true)
Then, based on the Status field, added permissions as needed. Example:
Grant user edit rights:
_api/lists/getByTitle('Listname')/items(ID)/roleassignments/addroleassignment(principalid=VarUserID,roledefid=1073741827)
Grant group Full Control:
_api/lists/getByTitle('Listname')/items(ID)/roleassignments/addroleassignment(principalid=VarGroupName,roledefid=1073741829

newitemper.png

Automation for modified items used the following to clear permissions:

Clear User from Permissions
/_api/web/lists/getbytitle('smsapvendorforms')/items(ID)/roleassignments/removeroleassignment(principalid =VarUserID)
Clear group from permissions

/_api/web/lists/getbytitle('smsapvendorforms')/items(ID)/roleassignments/removeroleassignment(principalid = VarGroupName)
Then, based on Status field, re-added permissions as needed.

View solution in original post

1 REPLY 1
Highlighted
Resolver II
Resolver II

Re: Change Permissions for SharePoint List item on New and Edit

To get this to work for New Items, as well as after editing items I ended up with two Automation's. 

First Automation,  which runs on created items, first cleared permissions using: _api/lists/getByTitle('Listname')/items(ID)/breakroleinheritance(copyRoleAssignments=false,clearSubscopes=true)
Then, based on the Status field, added permissions as needed. Example:
Grant user edit rights:
_api/lists/getByTitle('Listname')/items(ID)/roleassignments/addroleassignment(principalid=VarUserID,roledefid=1073741827)
Grant group Full Control:
_api/lists/getByTitle('Listname')/items(ID)/roleassignments/addroleassignment(principalid=VarGroupName,roledefid=1073741829

newitemper.png

Automation for modified items used the following to clear permissions:

Clear User from Permissions
/_api/web/lists/getbytitle('smsapvendorforms')/items(ID)/roleassignments/removeroleassignment(principalid =VarUserID)
Clear group from permissions

/_api/web/lists/getbytitle('smsapvendorforms')/items(ID)/roleassignments/removeroleassignment(principalid = VarGroupName)
Then, based on Status field, re-added permissions as needed.

View solution in original post

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Users online (6,963)