cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
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
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
Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Top Solution Authors
Users online (6,145)