Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Possible to change file level permission on a document (in document library) with Visual studio 2012 workflow for SharePoint Online 2013?

share|improve this question

1 Answer 1

Its possible to set permissions using REST API in Workflow.

You can use these methods:

BreakRoleInheritance​

BreakRoleInheritance is just not documented and can be used using POST request:

https://your_sp_site.sharepoint.com/_api/web/lists/getByTitle('Test')/breakroleinheritance(copyRoleAssignments=true, clearSubscopes=true)

where

  • copyRoleAssignments – if true, this method copies the role assignments of the parent securable object when breaking inheritance; otherwise, this method adds the current user to the permission level that is required to manage the list item.
  • clearSubscopes – Indicates whether subscopes should be cleared or not.

AddRoleAssignment

Instead of the Add there is AddRoleAssignment method that also can be called using POST request (NOTE: this method works incorrectly in RTM release of SharePoint 2013!!!! It checks user within current item and if user is not found (usually as we've just broken inheritance) throws an exception. In SharePoint Online and March CU it works as expected):

https://your_sp_site.sharepoint.com/_api/web/lists/getByTitle('Test')/roleassignments/addroleassignment(principalid=20,roleDefId=1073741828) 

where

  • principalid - id of user or group within current site collection. You can get a list of users by executing using GET: https://your_sp_site.sharepoint.com/_api/web/siteusers
  • roleDefId - internal id of Role Definition (Read, Contribute, Full Control and so on). You can get a list of available role definitions using GET: https://your_sp_site.sharepoint.com/_api/web/roledefinitions​

Also you can find workflow activities to work with permissions on codeplex

share|improve this answer
    
Please avoid link only answers as shown in our help section: "Provide context for links Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline." –  Benny Skogberg MCSA Nov 19 '13 at 18:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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