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

I'm working on a SharePoint 2013 document library which is shared with all of the site users and contains all the documents handled by the system. I have enabled a workflow that follows the company's business processes for handling those documents.

Since the information that will be handled by the library can be very sensitive, it is required that documents on the library are only visible to the people that are involved on each document's process. I've created a SharePoint 2010 Workflow that sets individual item permissions for each document depending on the document status.

The problem I have right now is that when a document is created/opened by Word, SharePoint locks that document for edition and the Workflow can't change its permissions. This is a problem because when a user creates a new document, the document remains visible for all users that can access the library until the user closes the document and SharePoint releases the document for edition.

Is there any way to override that editing lock? Or is there any way to set the default permision of the library so users only can see the documents they uploaded?

share|improve this question

2 Answers 2

You can create a custom view "My views" and set that view as default view.

You can create default as mentioned in this post: http://www.sharepointchick.com/archive/2009/07/16/creating-a-custom-view-that-filters-on-the-current-user.aspx

share|improve this answer
    
Thanks for your answer! I'm aware that this kind of filtering can be donde but it is not an effective solution for me since the actual permissions of the documents are not changed and they can be accessed by other means. –  ctorresmx May 14 at 17:29
    
You can set the permissions after that. May be you can create a timer that will update the permissions. As there is no way you can edit checked out document. –  Aanchal May 14 at 18:07
    
The workflow waits for the document to become unchecked, that's not an issue. Ideally, the default permission for the library should let users see only the documents they uploaded so there's no chance that anyone else can access a document they sholdn't, even for a few seconds (or worse, minutes). –  ctorresmx May 15 at 15:30
up vote 0 down vote accepted

After some research I finally found a solution for this. As I said before, it is critical that the documents have the permission level set as soon as they are uploaded since we don't want users to have any chance to get to see any documents that they're not authorized to see.

I couldn't find a way to do this OOTB, and as I read I don't think it's possible. That's not really an issue for me but I understand many prefer doing things OOTB.

At the end I was able to change the file permissions by using an event receiver. Here's the code based on this articles:

http://mohamedakb.blogspot.mx/2012/06/set-item-level-permission.html

 public override void ItemAdded(SPItemEventProperties properties)
   {
       SPSecurity.RunWithElevatedPrivileges(delegate()
       {
           try
           {
               using (SPSite site = new SPSite(properties.SiteId))
               {
                   using (SPWeb web = site.OpenWeb(properties.RelativeWebUrl))
                   {
                       SPListItem item = web.Lists[properties.ListId].GetItemById(properties.ListItem.ID);  

                       web.AllowUnsafeUpdates = true;
                       SPUser user = web.CurrentUser;

                       item.BreakRoleInheritance(false);
                       SPRoleDefinitionCollection webroledefinitions = web.RoleDefinitions;
                       SPRoleAssignment roleassignment = new SPRoleAssignment(user);
                       roleassignment.RoleDefinitionBindings.Add(webroledefinitions["Full Control"]);
                       item.RoleAssignments.Add(roleassignment);
                       item.SystemUpdate();
                   }
               }
           }
           catch (Exception ex)
           {
               properties.Status = SPEventReceiverStatus.CancelWithError;
               properties.ErrorMessage = ex.Message;
               properties.Cancel = true;
           }
       });
   }

Note that I'm using item.SystemUpdate() instead of item.Update(), which according to this article overrides the editing lock on the files. http://www.novolocus.com/2012/07/25/sharepoint-check-out-vs-lock/

share|improve this answer

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.