January 21, 2016

How to set View level permission for a List/Library in SharePoint

7115 Views

Recently, I got a requirement from my boss where he wanted to set view level permission on each view in a Document library. In OOB SharePoint, any user with read access can navigate to any views and we don’t have any permission which can be applied on the list view.

 After doing a bit of research, I found out a way to do this out of the box and of course with the help of SharePoint Designer. Approach is to create each views as Library items and apply Item level Permissions. So let’s begin!

Note: This approach will work in both on premises as well as in Office 365.

Step 1: Create a folder where we will keep all our View Items files and hide this entire folder.

1. Create a Content Type taking Folder as base Content Type. Let’s call it "ViewFiles".

2. Create a Document Library, in my example its "Company Documents". Add "ViewFiles" Content type and create a folder with some name, say "ViewItems". This folder will contain all the List View pages and we will hide this entire folder using the Filter option in view.

Let’s create 2 views:

  • Create "Employee View" with the below filter condition as shown in the image. You can add other condition here as well.

  • Manager View: Create similar to the above Employee View.

3. Create 2 SharePoint groups:

In my example-

  • Employee Group: User from this group can only access "Employee View"
  • Manager Group: User from this group can access "Manager View" and also "Employee View".

Both groups have a Contribute access to the entire site.

4. Remove "ViewFiles" Content Type as we don’t need them in the File-New Dropdown. Go to "Company Documents" library, Click on Library Settings and click on "Change new button order and default content type" and Uncheck ViewFiles content type.

Step2:

Copy Views to "ViewItems" folder using SharePoint Designer.

Export files:
  1. Open "All Files" and Select "forms" folder.
  2. Select "Employee View.aspx" item. Select Export File.
  3. Follow the same procedure for "Manager View.aspx".

Import Files:
  1. Select All Files, Click on "Company Documents" library, click on ViewItems.
  2. Click on Import Files and Import the 2 views. These 2 items are inside the   "ViewItems" Folder.

Assign Permissions:
  1. Right click on newly copied View and click on "Preview in Browser"

  2. Click on "Permissions"

  3. Click on "Stop Inheriting Permissions" and Click on "Grant Permissions" in the ribbon
  4. Add Employee Group, Manager Group and assign them "Contribute Permission"

  5. Follow the same steps for Manager View, but add only Manager Group with Contribute permission

You are all Set now. 2 views with unique permissions. Login As "Employee" and Click on Manager View. You should get Access Denied error. Login as "Manager" and you should be able to navigate both Views without any issues.

Hope this helps some one out there :)

3 Replies to “How to set View level permission for a List/Library in SharePoint”

  1. Ravi,
    Excellent way to manage “view permissions”.
    I tried to do the same with a list but now luck. When I open the view aspx I do not have option to manage permissions.
    Any suggestion?
    thanks

  2. This is Good. But I need quiet different.
    Suppose there are two managers Manager1 and Manager2. And User1 and User2 reports to Manager1 and User3 and User4 reports to Manager2.
    Here Manager1 can see items added by User3 and User4.

    I want that, Manager1 can see Items added by User1, User2 and himself only.
    same way Manager2 can see item added by User3 and User4 only .

    Suppose Manager1 and Manager2 reports to Manager3,
    then Manager3 can see items added by User1, User2, User3, User4, Manager1 and Manager2.

    Thanks in Advance.

Leave a Reply

Your email address will not be published. Required fields are marked *