Sometimes when building any solution based on SharePoint we need to hide a list from the site contents, for several reasons. The list can be creted to be used only by an automated solution and not to be updated or accessed by users. Even if we restrict permissions to read-only in the list, this can cause some confusion in users.
Using SharePoint Designer we can mark a list as hidden from the site contents easily, and the same can also be done using PowerShell or SharePoint APIs.
But not all the time it’s possible to use/install PowerShell or SharePoint Designer in our computers. And also it’s important to bear in mind that SharePoint designer will be discontinued at some point in the near future.
So how can we do it without PowerShell or SharePoint designer?
Use a Power Automate Flow and the powerful Send an HTTP Request to SharePoint action!
The basics
To hide a list from the site contents, we simply need to make a call to the SharePoint REST API using the following parameters, as in the sample below:
- SiteUrl: your site URL
- Method: POST
- Uri: _api/web/Lists/getbytitle(‘Your list title’)
- Headers:
- X-HTTP-Method: Merge
- If-Match: *
- Body: { ‘Hidden’: true}
Full working sample
You can get a full working flow from this link and import it.
It’s a manually triggered flow, so you need to run it manually to hide a SharePoint list, using as parameters:
- Site Url
- List title
- Hidden (Toggle on hides a list/Toggle off makes a hidden list visible again)
Sample flow working and hiding a list:
Note that the ‘Issue tracker’ list is hidden after the flow is executed. This flow also sends you the link of the list in an e-mail message when successful:
And the link to the failed flow run when it fails:
Conclusion
With Power Automate and the SharePoint REST API we are able to hide or show lists from the site contents.
Note that this does not remove any permissions from the list. Users with the list link will still be able to access it via the direct list URL.
[…] Source link […]
How do you reverse this? How can I show something that was hidden? Unhide something??
Use { ‘Hidden’: false} in the request body. The sample flow I posted here has dynamic value detection from its inputs, you can use it as sample to test…
https://github.com/michelcarlo/blogsamples/tree/main/PowerAutomate-HideSharePointList
Do you need to have full control on the site or SCA rights for this to work? If it goes to a site behind Teams, should you be one of the team owners? I got back “Invalid JSON. A token was not recognized in the JSON content.” My guess is that it is because I wasn’t an owner to that team’s site. Don’t really want to test this in prod, but I might need to.
Never mind. I had “True” instead of “true”.
HAHA no problems, good you sorted it😀
Hallo Michel
How About error like this:
The request ETag value ” does not match the object’s ETag value ‘”10″‘.
clientRequestId: ea7549b7-ac77-4abc-81d6-99f4daa638a1
serviceRequestId: c278d5a0-d036-2000-7de8-6b18575790de
Hey Agus,
Have you used the If-Match header correctly? Mostly the error is due to that.