In 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:
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.
- 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:
This will add PermissionLevel to the bottom of the schema.
- 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:
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.
- Rename the Send HTTP Request to something short eg GetPermissionID. This will make extracting the Permission ID from the returned body easier.
- 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:
- Now we need to modify the URI string that gives the permission to use your new variable rather than the hard coded contribute permission.
- Return to the main flow and add the Permission level to the HTTP action.
- 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.
This method works for custom permission levels.
“How to manage permissions on a SharePoint List Item using Microsoft Flow! – Series Navigator:
- 1) How to change List Item permissions
- 2) How to add Contribute permission
- 3) How to split a Flow into reusable parts
- 4) How to set named Permission Levels
- 5) Getting responses from called Flows