Reset permissions on a SharePoint list item using Power Automate

When working with SharePoint you might have a situation in which you’ve assigned permissions to another user. But what if you want to reset this change using a Power Automate flow?

You could remove the permissions on the object with the build in Power Automate “Stop sharing an item or file” function. But if you do this all permissions of the item will be gone.

What we want is for the object to inherit the permissions of its parent. There is (as far as I’ve seen) no Power Automate function which allows us to do this. In the SharePoint API there is a function called ‘ResetRoleInheritance’ which does exactly what we want.

_api/web/lists(‘listid‘)/items(‘itemid‘)/ResetRoleInheritance

Note: Replace listid and itemid by your values.

So what we can do is make a POST to the SharePoint API:

function to call the ResetRoleInheritance function on the SharePoint API.

After running above command you will notice that the permissions of the item wil now no longer be unique and match the permissions of the list or parent.

There is a caveat. The above call will have an error if the item does not have unique permissions.

To avoid this we should verify first that the item is indeed using unique permissions. Once again we will need to use a function of the SharePoint api. Here we will call the ‘HasUniqueRoleAssignments’ function.

_api/web/lists(‘listid’)/items(‘itemid’)/HasUniqueRoleAssignments

When calling the above function we will get a json response containing a boolean response response for the value HasUniqueRoleAssignments. So we make the following call:

function to call the HasUniqueRoleAssignments function on the API

To parse the result of the above request you can use the ‘json parse’ function of Power Automate.

Parse that json!

So when putting it all together you:

  1. First determine if the item has unique permissions
  2. Parse the result
  3. Add a condition to your flow for the ‘HasUniqueRoleAssignments’ value. Check if it is true.
  4. When true, call the ResetRoleInheritance function
  5. Success

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: