I see you can make a list hidden by using SharePoint Designer (http://www.sharepointdiary.com/2013/06/how-to-hide-list-or-library-in-sharepoint.html) which I am not interested in.
It is okay if the list is available via the URL.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI see you can make a list hidden by using SharePoint Designer (http://www.sharepointdiary.com/2013/06/how-to-hide-list-or-library-in-sharepoint.html) which I am not interested in.
It is okay if the list is available via the URL.
Try this
var list = ctx.Web.Lists.GetByTitle(listTitle);
list.Hidden = true;
list.Update();
ctx.ExecuteQuery();
Source: Hide document library using CSOM
Note that in the source they use BreakRoleInheritance to prevent users from accessing the list.
Hidden
should be false
. But using true
will hide the list (while still letting it be accessible with a direct link).
ExecuteQuery
in JSOM)
Thanks for everybody's responses. Close to jpussacq's question I was able to get it working by using the lists hidden attribute by using the set_hidden(true) in the following way:
//JSOM example
ExecuteOrDelayUntilScriptLoaded(hideListItem, "sp.js");
function hideListItem(){
var ctx = new SP.ClientContext().get_current();
var thisList = ctx.get_web().get_lists().getByTitle('My List');
thisList.set_hidden(true);
//must be updated before loading
thisList.update();
ctx.load(thisList);
ctx.executeQueryAsync(function(){
});
}