0

I am using a workflow to set item level permission. But it is not working. I already used some suggestion, like break role inheritance, add role. But it is not working.

I also tried it using simple rest API call in a browser console. role inheritance is breaking successfully through rest API. But when i tried to assign a new role, it is not working.

Can anyone help?

  • Can you share the snippet of what you are trying to do in the question. It would help us help you troubleshoot. – Swayam Siddha Jul 28 '17 at 5:16
  • Great article regarding this using Javascript/Rest api can be found here – nbi Aug 10 '18 at 11:34
4

Yeah, This is possible in workflow using REST API. Below are the steps which you need to follow.

Step 1: Whatever REST you are writing that should be part of App Step. enter image description here

enter image description here

Step 2: As shown in screen shot you will have to write your commands in a workflow. There are some variables which you need to assign.

Step 3: Very first, you need to build dictionary where as variable name is ContextHeaders in aboveshown screenshot.

enter image description here enter image description here

Step 4: Next need to set API url in very next line. That API url should be something like https://YourSite/_api/contextinfo and HTTP method should be HTTP Post.

Step 5: Next you need to set Get and that should be like d/GetContextWebInformation/FormDigestValue

Step 6: Again you need to build your dictionary for request headers to make REST call to break inheritance.

enter image description here enter image description here

Step 7: Next you need to set variable to whom you want to give permissions after breaking the inheritance. In example shown above, we are assign some group ids to variable userIds.

Step 8: Write REST to break the inheritance. Your REST should look like https://YourSite/_api/web/lists/getByTitle(%27YourListTitle%27)/items(%27[%Current Item:ID%]%27)/breakroleinheritance(copyRoleAssignments=false, clearSubscopes=true). HTTP Request Type will be HTTP POST.

As we are breaking item level inheritance that's why we are going with Current Item ID.

Step 9: You need to set variable roleDefinition. This role definition is for, what permission level you want to assign to particular user.group ID.

Step 10: For assigning unique permission to User/Group id, again you will have to make a REST call. your REST should look like https://YourSite/_api/web/lists/getByTitle(%27YoutListTitle%27)/items(%27[%Current Item:ID%]%27)/roleassignments/addroleassignment(principalid=[%Variable: Id%],roledefid=[%Variable: roleDefination%])

This is how you can break inheritance and assign unique permissions.

I hope this will help you. Still, if you have any thing, please write back.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.