1

Is it possible to change the visibility (Hidden or not) of a list using the REST API?

I need to hide some (system) lists from the users, but I would very much like not to use custom permissions if possible.

Basically I need to know how to contruct the webservice using this info: https://msdn.microsoft.com/en-us/library/office/jj245232.aspx

10
  • Are saying that you do not want to break permissions at list level? – harshal gite Nov 8 '18 at 18:52
  • 1
    No I would very much like not to change permissions from a performance perspective (I already know how to do this). But I would like to set the property "hidden" to true on a document library. – Morten K Nov 9 '18 at 6:21
  • do you want to directly access the REST api? Or would using Powershell work for you too? – Robert Wagenaar Nov 9 '18 at 8:47
  • 1
    @RobertWagenaar I would need direct access via the REST interface as I need to execute it from a designer workflow. – Morten K Nov 9 '18 at 8:54
  • When do you want to hide the list? You will have to add the code to the master page to execute it throughout the site. – harshal gite Nov 9 '18 at 11:17
3

Yes it is possible using REST API.

You can do that in the workflow by calling the REST API. I have done that using jQuery below which you can replicate in the workflow:

var itemPayload = { 
            "__metadata": { "type": "SP.List" }, 
            "Hidden": true,
        };

jQuery.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('Custom List')",
    type: "POST",
    data: JSON.stringify(itemPayload),
    headers: {
        "accept": "application/json;odata=verbose",
        "content-Type": "application/json;odata=verbose",       
        "IF-MATCH": "*",
        "X-HTTP-Method": "MERGE",
        "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
    },
    success:function(data){
        console.log(data);
    },
    error:function(data){
        console.log(data);
    }
});

Reference - Working with lists and list items with REST

1
  • Well the JQuery works as expected, I'm having a little trouble figuring out the workflow part, but that's should just be a matter of testing a bit more. Thanks for the info, that really helped me a lot! – Morten K Nov 9 '18 at 11:45
-2

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

Open the site in SharePoint Designer, Right click the target list >> Choose List settings >> General Settings

  1. Check the "Hide from browser" option
  2. Uncheck the "Display this list on quick launch" option
  3. Click on "Save" button to apply the changes

Now, Open it SharePoint site in browser and verify that your list is hidden. enter image description here

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:

  1. Go to "All Files" folder from the SharePoint designer left pane Treeview.
  2. Right click on your hidden list >> Choose Properties
  3. 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.

3
  • I'm asking for the REST API in order to automate the process. I'm well aware that you can do it manually, but that has zero to do with the question here. I even stated in the comment thread earlier where you participated that I need to be able to use it in a workflow. – Morten K Nov 10 '18 at 20:56
  • I asked you when you want to hide the list u said once property on iyem is set – harshal gite Nov 10 '18 at 21:02
  • I was asking for a solution using the REST API for a reason, you are suggesting to do it manually - which is counterproductive in nearly all use cases... – Morten K Nov 10 '18 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.