Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Somehow a developer has managed to royally screw up a site collection. The site collection has the Publishing Feature enabled and it's working fine. A botched migration from 2007 to 2010 has caused some issues. Now the "Site Collection Documents" and "Site Collection Images" show up twice when you go to the View All Site Content page. In addition, clicking on the lists yields an error as it can't seem to find the list.

The fun part is opening up SharePoint Designer. You can bring up the lists and they actually have a GUID. Trying to delete the lists in SPD yields an error message "Could not save changes. This list cannot be deleted" (regardless of what account I use). And I even tried using a PowerShell command to delete the list. I get the same error, "Cannot delete list".

I suspect the list doesn't exist but there's still a record of it in the database. The only way I can think of fixing this is to do a direct database edit, which I really want to avoid.

Looking for new suggestions or ideas.

share|improve this question
4  
Always us developers, isn't it Bil? ;) I blame your IT Pros and their botched migration myself :P –  James Love Dec 8 '11 at 13:54
    
When you open the site up in SharePoint Manager, what do you get then? Able to delete through that? What does ULS say when you attempt to delete the list with any method? –  James Love Dec 8 '11 at 13:55

3 Answers 3

I hate answering my owner questions here but found the problem. There's a flag on lists you can set a list to AllowDelete or not (this is for lists that are critical to the operation of a feature). The flag on these lists were set to False and wouldn't allow deletion. It still doesn't explain why the list was showing up twice both in the UI and SharePoint Manager (but only once in SharePoint Designer).

The fix is to use SharePoint Manager to set the flag on a list as AllowDelete = True then you can delete it (through SharePoint Manager or SharePoint Designer). Note that you cannot get to this property through SharePoint Designer so you either have to use SharePoint Manager or write some code (C#, PowerShell, or JavaScript) to set this flag.

It would have been more helpful if the error message was something along the lines of "This list is configured to not allow deletion." instead of just "Cannot delete list".

Edit: You can also use the PowerShell described in another answer. I haven't tested it but it should work.

share|improve this answer
    
Thanks for the great description of how you solved the problem, I'll be sharing this with a couple of people here that have encountered that problem. –  GavinB Dec 8 '11 at 20:06

you may get some clues by checking the exception it throws upon deletion - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.delete.aspx

share|improve this answer
    
1. $fooweb = Get-SPWeb fooUrl 2. $foolist = $fooweb.Lists["fooList"] 3. $foolist.AllowDeletion = $true 4. $foolist.Update() 5. $foolist.Delete() 6. $fooweb.Dispose() –  Supriyo SB Chatterjee Dec 8 '11 at 16:28
    
dang! can't figure out this "mini-Markdown formatting".. the POSH script excerpt above should force a list deletion.. –  Supriyo SB Chatterjee Dec 8 '11 at 16:29
    
Surround the code you wnat highlighted in ` (backtick) characters. –  James Love Dec 9 '11 at 18:16

Here is an example in C#

var web = SPContext.Current.Web;
var links = web.Lists.TryGetList("Links");
if (links != null)
{
    links.AllowDeletion = true;
    links.Update();
    web.Lists.Delete(links.ID);
    web.Update();
}

See why to use web.Lists.Delete()

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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