Wednesday, June 5, 2013

How to Hide a List or Library in SharePoint?

How to Hide a SharePoint list or library from browser? 
But why? Because, My custom application uses some configurations which should be stored and retrieved from a SharePoint list, but it must not be visible to end-users to avoid any mess. So, we got to hide our configuration list from users.

We don't want the configuration list to be available to users, but visible only for the custom application code to read/write in it.  So lets hide the configuration lists from "View All Site Content" page.

To hide a SharePoint 2007 or SharePoint 2010 list or library, either we've to use SharePoint API (Set SPList.Hidden property of the SharePoint list programmatically with either C# Object Model code or PowerShell) or use SharePoint designer.

Even SharePoint itself uses lots of hidden Lists & Libraries for its own operations (E.g. "Content and Structure Reports", "Master Page Gallery", "Form Templates", "User Information List", etc)

To hide a list in SharePoint 2010 using PowerShell:
To hide library in SharePoint, use the below PowerShell script.

#Define the Web URL & List Name
$WebUrl = ""
$ListToHide = "AppConfig"

#Get the Web
$web = Get-SPWeb $WebUrl
#Get the List
$list = $web.Lists[$ListToHide]

#Set the Hidden Property
$list.Hidden = $true

#Displose Web Object

Hide SharePoint 2013 List using CSOM-PowerShell:
#Load SharePoint CSOM Assemblies
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null

#Variables for Processing
$SiteUrl = ""
$LibraryName="Team Docs"
#Setup Credentials to connect
$Credentials = [System.Net.CredentialCache]::DefaultCredentials

#Set up the context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) 
$Context.Credentials = $credentials

#Get the List and Make it hidden
$list = $Context.Web.Lists.GetByTitle($LibraryName)
$list.Hidden = $true

Hide a Document Library in SharePoint using C# Object Model Code:
using (SPSite site = new SPSite(""))
    using (SPWeb web = site.OpenWeb())
       SPList configList = web.Lists["AppConfig"];
       configList.Hidden = true;
This method of hiding SharePoint list applies to any SharePoint List, Document Library, picture library, etc.
hide sharepoint list from view all site content
This is how we can actually hide the lists from user view  programmatically using C# or PowerShell.
Programmatically setting the Hidden property of the list will also hide the list from Quick Launch bar.  However, It is possible that the document library link may be placed in Quick launch manually and still appears! so take care of it.

Hide a list from users using SharePoint Designer:
Here is how we can hide a document library or list in SharePoint 2010:

  • Open the site in SharePoint Designer, Right click the target list >> Choose List settings >> General Settings
  • Check the "Hide from browser" option
  •  Uncheck the "Display this list on quick launch" option
  •  Click on "Save" button to apply the changes
hide document library in sharepoint 2010
Now, Open it SharePoint site in browser and verify that your list is hidden.

To Unhide a Hidden list in SharePoint Designer:
Unhide a hidden list is little tricky! The above steps to hide list in SharePoint, will also hide the list from SharePoint designer's "Lists and Libraries" section. So, To unhide the list:
  • Go to "All Files" folder from the SharePoint designer left pane Treeview.
  • Right click on your hidden list >> Choose Properties
  • Revert back the settings "Hide from browser" to false and "Display this list on quick launch" to True! Save your settings.
  • Now, you'll get the hidden list back in the browser and in the SharePoint designer.
Remember, although list's hidden property is set, it will not stop users from directly hitting the list URL in browser and get into the list! E.g.
If you really concerned about the confidentiality of the list, To hide a list from users: You have to break list permission inheritance and remove all user permissions from the list. So that the list data will not be visible to any users (But this doesn't control Site collection Admins, Farm Admins with Web Application Policy).

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...