[SOLVED] UpdateList method can't unhide lists

Nov 12, 2012 at 7:20 PM
Edited Nov 12, 2012 at 7:25 PM

Hello guys!

I'm using the UpdateList method to hide some lists libraries, while they don't need to be used.

When I try to unhide then, it isn't working ;p

I'm using the following code to hide then:

$().SPServices({
  operation: "UpdateList",
  listName: "LibraryName",
  listProperties:"<List Hidden='true' />",
  completefunc: function (xData, Status){
    console.log($(this))
  }
});

And the following code to try to unhide:

$().SPServices({
  operation: "UpdateList",
  listName: "LibraryName",
  listProperties:"<List Hidden='false' />",
  completefunc: function (xData, Status){
    console.log($(this))
  }
});

Any suggestion?

Thanks!

Nov 13, 2012 at 10:42 AM

Have you looked at the response of the unhide request? Also, try using TRUE and FALSE (uppercase) as sometimes this matters.

Nov 13, 2012 at 3:27 PM
Edited Nov 14, 2012 at 9:34 AM

Thanks @spevilgenius, but I'm still having the same issue (using 'false', 'False' and 'FALSE').

After some tests I conclude the following:

When I use the following code to show the properties:

$().SPServices({
  operation: "UpdateList",
  listName: "Doc2",
  completefunc: function (xData, Status){
    console.log($(this))
  }
});

[UPDATE]: it's better to use GetList instead UpdateList to get list properties:

$().SPServices({
  operation: "GetList",
  listName: "Doc2",
  completefunc: function(xData, Status) {
    console.log($(this));
  }
});

I get this response:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><UpdateListResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/"><UpdateListResult><Results><NewFields /><UpdateFields /><DeleteFields /><ListProperties DocTemplateUrl="/sites/PUMA/Doc2/Forms/template.doc" DefaultViewUrl="/sites/PUMA/Doc2/Forms/AllItems.aspx" MobileDefaultViewUrl="" ID="{71899C1A-20FE-40E9-B3E4-BEF0B7B89A06}" Title="Doc2" Description="" ImageUrl="/_layouts/images/itdl.gif" Name="{71899C1A-20FE-40E9-B3E4-BEF0B7B89A06}" BaseType="1" FeatureId="00bfea71-e717-4e80-aa17-d0c71b360101" ServerTemplate="101" Created="20121113 04:03:54" Modified="20121113 04:03:55" LastDeleted="20121113 04:03:54" Version="1" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="67112968" ItemCount="0" AnonymousPermMask="0" RootFolder="/sites/PUMA/Doc2" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailInsertsFolder="" EmailAlias="" WebFullUrl="/sites/PUMA" WebId="dddd41cf-6f87-4ae2-9aa0-901c4d85533a" SendToLocation="" ScopeId="d3c29d60-1974-46da-ab58-bcf1d2d0cda1" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="False" EnableModeration="False" EnableVersioning="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnableMinorVersion="False" RequireCheckout="False" /></Results></UpdateListResult></UpdateListResponse></soap:Body></soap:Envelope>

That's ok.

Now, I'll hide the list with the following code:

$().SPServices({
  operation: "UpdateList",
  listName: "Doc2",
  listProperties:"<List Hidden='true' />",
  completefunc: function (xData, Status){
    console.log($(this))
  }
});

Perfect, the list is hidden!

[UPDATE]: the list is really hidden as doing it by SharePoint Designer. Details here: http://goo.gl/6OsOG

The main problem is that the list can't be 'unhidden' using this method (UpdateList).

After all, if we use the first code to show the list properties (after turning the list visible), we will see again the property Hidden="False".

Thanks for all help and suggestion :D

Nov 13, 2012 at 3:37 PM
Edited Nov 13, 2012 at 3:50 PM

Changing another property (to true or false), for example ShowUser, is working well!

Nov 14, 2012 at 10:32 AM

Can you check the properties to see if there is a group proerty set on the hidden list. Sometimes I have seen "_hidden" as a group property so even though you set the hidden property, it is not assigned to a group.

Nov 21, 2012 at 10:42 AM

Very interesting... But how could I find if there'a a group property?

Can I use a method with SPServices to do it?

Thanks!

Nov 21, 2012 at 11:20 AM

I have some news!

It's working (in parts), because when I change the property Hidden to False, the list/ library will be available on All Site Content view (/_layouts/viewlsts.aspx).

The list remain hidden by its own configuration, on Settings > List Settings > Title, Description and Navigation > Display this list on the Quick Launch.

I don't know if this behavior is 'by design', because SharePoint Designer does the same (and I never paid attention on it).

Although I'm trying to find a way to totally hide and unhide the lists/ libraries I want, turning it available or not without need to change the list configuration after use any method.

Thanks all!

Nov 21, 2012 at 11:32 AM
Edited Nov 22, 2012 at 12:05 PM

Finally solved!!

To 'totally' hide:

$().SPServices({
  operation: "UpdateList",
  listName: "YourListName",
  listProperties:"<List Hidden='true' />",
  completefunc: function (xData, Status){
    //console.log($(this))
  }
});

To 'totally' unhide:

$().SPServices({
  operation: "UpdateList",
  listName: "YourListName",
  listProperties:"<List Hidden='false' OnQuickLaunch='true' />",
  completefunc: function (xData, Status){
    //console.log($(this))
  }
});

OnQuickLaunch property is the secret, that is not listed on UpdateList method:

http://msdn.microsoft.com/en-us/library/lists.lists.updatelist.aspx#5

Special thanks to Thomas Lee and Keith Dahlby that talk about it on comments ;p