Okay – so I’m trying to test some import issues with lists and decide to export an existing list that has documents set the way I need them. I run my import test and realize I’ve got more work to do so I go to delete the list via the browser. Hmm… the delete option isn’t there – no problem I say – there’s a forcedeletelist command that I just blogged about last week so I’ll use that. But what’s this – I ran the command and I got this error: "The requested delete operation could not be performed. (Exception from HRESULT:0x800720CE)".
Okay – what the heck! What’s the point of a "FORCE"deletelist command if it doesn’t FORCE the deletion of the list. So I did some testing and I discovered that the reason it couldn’t delete it was because there was a property called "AllowDeletion" which was set to false (my list was the "Documents" list which is part of the publishing feature so it’s set to not allow deletion). I checked this property out and it turns out that it’s a really simple property with public getter and setters (the later being unusual in my experience – I usually have to use reflection to hack the objects). So I set the property to true and then tried a simple SPList.Delete() and it worked like a charm.
So what did I conclude – forcedeletelist is misnamed and should be abandoned – I’ve created a new command called simply gl-deletelist which allows you to pass a "-force" parameter in to actually force the deletion of the list. Now granted – there may be cases in which mine still fails but at least it will handle the AllowDeletion setting! Here’s the code:
The syntax of the command can be seen below:
C:\>stsadm -help gl-deletelist stsadm -o gl-deletelist Deletes a list. Parameters: -url <list view URL> [-force]
Here’s an example of how to delete a list passing in the force parameter:
stsadm –o gl-deletelist -url "http://intranet/Documents/Forms/AllItems.aspx" -force