How to manage permissions on a SharePoint List Item using Microsoft Flow

2018-07-31

Fibonacci Elephant logo with Microsoft's Flow logoIn part 3 of this series we built a reusable flow to add contribute permission to one item for one person. Most examples found will give you the most common permission level ids. This post will walk through finding the roleDefId needed for any named permission level and will modify the HTTP request trigger to include the named permission.

This post uses the same list as previously which is a custom list with one column Requester added, which is a person column. The A link to Permission flow from the previous post is below:

Add Contribute Permission

There are two parts to the changes needed. Firstly we need to change the trigger event to include a Permission Level. Secondly we need to use that name to look up the Permission ID. That permission id can then be used in the final rest call.

  1. We can use the sample payload to create the updated JSON Schema. The sample does not need to contain real data, so should look like:
    {"SiteAddr":"value","ListName":"value","ItemID":1,"UserEmail":"Value","PermissionLevel":"Value"}

    This will add PermissionLevel to the bottom of the schema.
    HTTP trigger

  2. Then further down the flow we need to add actions for fetching the Permission Level ID. I suggest just after Initialise Variable – RequesterID. The first part is the URI string. The syntax for this is:
    _api/web/roledefinitions/getbyname('PermissionLevel')

    So add an action to set the URI string to this using the PermissionLevel from the trigger event of this flow and then do add Send HTTP request to SharePoint action.
    Set up URI string and send request

  3. Rename the Send HTTP Request to something short eg GetPermissionID. This will make extracting the Permission ID from the returned body easier.
  4. After the Send HTTP request action add another action to initialise a variable to store the Permission ID. This will require an expression based on the body of the GetPermissionID. Click in Value, then on Expression in the side box and enter the following:
  5. Now we need to modify the URI string that gives the permission to use your new variable rather than the hard coded contribute permission.
  6. Return to the main flow and add the Permission level to the HTTP action.
  7. Test your workflow still works.

Expand the Workflow

Now I can assign any permission level I added a Line Manager column to the list and added the action to give the Line Manager read permission.

Note

This method works for custom permission levels.

“How to manage permissions on a SharePoint List Item using Microsoft Flow! – Series Navigator:

 

(Visited 362 times, 1 visits today)

About the author 

Laura Graham-Brown

SharePoint Trainer, Consultant and Agony Aunt

Leave a Reply

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

2 Free Ebooks: How to govern Microsoft teams 

Download your 2 free Microsoft Teams governance Ebooks and learn the steps necessary to create a bullet-proof governance strategy.