The reported issue was that on the sites created with one of the definitions the users are able to delete 'Documents' library, but on the sites with the second definition the users are unable to do so. The Remove button is missing, like the picture below.
Both sites come with 'Documents' library when they are created.
I did some investigation and found that the library in the first template comes from the site definition. The site is designed to be deployed with such library. In the second template where the user cannot delete the library it comes from the web level feature 'SharePoint Server Publishing' that is activated in the RootWeb, this is also by definition design. You can also see this in the description of the library. Along with this library the 'SharePoint Server Publishing' feature creates some important lists and libraries like 'Pages' and 'Workflow Tasks' and couple more. By default this lists and libraries cannot be deleted, this is why the 'Remove' option is missing.
The ability a SharePoint list (lists and libraries are same object in SharePoint OM) to be removable or not depends by the value of property of the SPList object called AllowDeletion. If the value is True the list can be deleted if it is False you cannot delete it.
I explained this to the customer, but they required to have the ability to delete this particular library from the site in question. Luckily we can set the value of AllowDeletion in existing List or Library.
Be very careful when you delete such lists it can break your site! But in my case I decided that if the library is not used by the users or for site assets I can safely delete the 'Documents' library from one of the sites. Below is the PowerShell script I used to change the value of AllowDeletion property.
$web = Get-SPWeb('http://publish.auto.l/') $list = $web.Lists['Documents'] $list.AllowDeletion = $true $list.Update()
After this the Remove/Delete options are available in their usual locations Site Content, Content and structure, ..etc.
I tired this commands to delete the Documents library but it throws an error . The Property "Allow Deletion cannot be found in this object" Verify that the property exist and can be set.
ReplyDelete