Brian Farnhill Australian SharePoint Developer and Lecturer

"Cannot complete this action" when trying to create a document library

Tags: SharePoint

I came across a ssituation today where I was trying to create a document library in a site that I had recently worked on, but I found that as soon as I clicked "Document Library" on the create page, I would get the following error:

Cannot complete this action. Please try again.   at Microsoft.SharePoint.Library.SPRequestInternalClass.GetSchemaXML(String bstrUrl, String bstrListName, UInt32 sch, Boolean bOnlyViewAttributes, Boolean bExtendedFieldsProperties, ISPDataCallback pXMLCallback)    at Microsoft.SharePoint.Library.SPRequest.GetSchemaXML(String bstrUrl, String bstrListName, UInt32 sch, Boolean bOnlyViewAttributes, Boolean bExtendedFieldsProperties,ISPDataCallback pXMLCallback)

After looking around for some answers I came across this on the MSDN forums. The answer pointed me in the direction of looking at my custom site definition and what was defined in it. I figured if the code was looking for the web temp files as the forum answer suggested then chances are it was looking for the onet.xml file as well,which then led me to look at something that was obviously missing from my onet.xml file. I had (for whatever reason) missed the DocumentTemplates section, as in skipped the element completely. It didn't stop the site from working and until now no one had noticed any issues.

The good news though is that this is totally fixable without having to worry about the fact that its already in production and being used. I just took the DocumentTemplates section from the STS site definition onet.xml file and pasted it in to my onet.xml, and then did an upgrade of my WSP file. As soon as the upgrade was done I went back and found that everything was working as expected. So putting two and two together from that forum post (and this is just an educated guess) I would assume that the create page for a document library is referring to the onet.xml file for information on document templates that it should put in place. Not something I was aware was happening, but something I will definitely keep in mind for my next site definition!