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.
Copy Views to "ViewItems" folder using SharePoint Designer.
- Open "All Files" and Select "forms" folder.
- Select "Employee View.aspx" item. Select Export File.
- Follow the same procedure for "Manager View.aspx".
- Select All Files, Click on "Company Documents" library, click on ViewItems.
- Click on Import Files and Import the 2 views. These 2 items are inside the "ViewItems" Folder.
- Right click on newly copied View and click on "Preview in Browser"
- Click on "Permissions"
- Click on "Stop Inheriting Permissions" and Click on "Grant Permissions" in the ribbon
- Add Employee Group, Manager Group and assign them "Contribute Permission"
- 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 :)