I have item level permissions set up on SharePoint List, but i would like the ability to remove specific user access to some items. i'm seeing alot of information around adding users but nothing on removing users.
Any one have an idea on how to achieve this please?
Solved! Go to Solution.
To modify the item permission,
1. You have to break the inheritance from the parent which can be done using the below endpoint
_api/web/lists/getByTitle(<List Title>)/items/getById(<Item id>)/breakroleinheritance(copyRoleAssignments=false,clearSubscopes=true)
2. Find the permission level ID.
_api/web/roledefinitions/getByName('contribute')
3. Get the user id
4. You have to assign the user the above roledef id
_api/web/lists/getByTitle(<List Title>)/items(<Item ID>)/roleassignments/addroleassignment(principalid=<user id>,roledefid=<roledef id>)
You can try using 'Send Http request to SharePoint' using the REST API to change the permission of an item.
Please refer the below links.
@sudharsan1985 none of the links have what i'm looking for which is the ability to remove a user from an item that has item level permissions
To modify the item permission,
1. You have to break the inheritance from the parent which can be done using the below endpoint
_api/web/lists/getByTitle(<List Title>)/items/getById(<Item id>)/breakroleinheritance(copyRoleAssignments=false,clearSubscopes=true)
2. Find the permission level ID.
_api/web/roledefinitions/getByName('contribute')
3. Get the user id
4. You have to assign the user the above roledef id
_api/web/lists/getByTitle(<List Title>)/items(<Item ID>)/roleassignments/addroleassignment(principalid=<user id>,roledefid=<roledef id>)
Hi @Gottijay2000 I'm delving back into my memory to when I used to do more SharePoint development, and if I remember correctly then there wasn't an explicit "remove" endpoint. The way that we did it was to reset and reapply the permissions without the user that you wanted to remove.
Is it too late to consider using SharePoint groups for your permissions instead? They are much more manageable through code.
Please mark the correct response as a solution to help others in the community.
Anonymous' reply is a better answer to the initial question than the one that is currently marked as a solution. The question was if there was a way to remove a specific user's permissions on an item, which is what Anonymous' answer does. Whereas the suggestion that is currently marked as solution really only adds permissions for a user after breaking permission inheritance. A workaround could be to remove all permissions for all users and then reassign permissions for all users that still need them, as suggested by MattWeston365. While that is a way to achieve the desired endgoal, it's a workaround that, depending on your list and number of users, may result in a lot of unnecessary action requests from your flow.
So, to confirm Anonymous' answer, the below action removes one specific permission from one specific user, on one specific item. Do note, though, that you do need to break permission inheritance first. If you're going to need to assign unique permissions for all items in your list, it's best to break inheritance on your entire list. If you only need unique permissions on a single item, then you can break inheritance using the HTTP request described in step 1 of sudharsa1985's solution.
The following action works for me.
The URI is:
_api/web/lists/getbytitle('Meeting Notes')/items(90)/roleassignments/removeroleassignment(principalid=<userId>,roleDefId=<permissionID>)
To get the user's principal ID, you need to make an HTTP request to the following URI:
_api/web/siteusers/getbyemail('jsmith@mysite.com')
The URI to get the roledefID was already mentioned above, but I'll repeat it here for completeness sake:
_api/web/roledefinitions/getByName('contribute')
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Read the latest about new experiences and capabilities in the Power Automate product blog.
If you are a small business ISV/Reseller, share your thoughts with our research team.
User | Count |
---|---|
25 | |
23 | |
9 | |
9 | |
7 |
User | Count |
---|---|
40 | |
35 | |
22 | |
20 | |
13 |