The requirement was to hide certain List or Document Library in a site. The following example shows how can it be done using object model. I would like to bring out some points: When a list is made hidden, it does not appear under "All Site Content" and Quick Launch". However, if user has created an explicit link to the list, it still appears. Also, if a user knows the URL, the hidden list can still be accessed. Item cannot be made hidden with this method. If the requirement is to block user from accessing the list, removing the permission is the ONLY way to achieve it. using (SPSite mySite = new SPSite("Site URL")) { ...
SharePoint | SharePoint Online | Angular | jQuery | REST | JSOM | Power Automate | Flow | Power Apps