Wednesday, June 24, 2009

Error message when checking in a document from office 2003

In a custom solution I recently worked on we were receiving an error from office applications when we tried to check in documents from within office 2003 applications like word or excel. The error was: "Cannont perform this operation. The file is no longer checked out or has been deleted" After a lot of digging, I found that the fault was in the custom content types that we deployed as features. The problem was that the person who wrote the CAML for the content types that inherit from the "Document" content type thought (understandably so) that it is enough to specify only the fields that the custom content type adds on top of the built in column. This meant that the content type did not have the right columns for file name for example. This was ok in the web UI or in office 2007 - but office 2003 must have some hard coded references that it missed, and it kept throwing errors. The solution was simple - add a reference to the built-in columns in each content type - even if it does inherit from the document content type. The following are the columns I had to add to solve the issue:

<!-- out of the box document columns--> <fieldref id="{5f47e085-2150-41dc-b661-442f3027f552}" name="SelectFilename"> <fieldref id="{8553196d-ec8d-4564-9861-3dbe931050c8}" name="FileLeafRef" required="TRUE"> <fieldref id="{8c06beca-0777-48f7-91c7-6da68bc07b69}" name="Created" hidden="TRUE"> <fieldref id="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" name="Title" required="FALSE" showinnewform="FALSE" showineditform="TRUE"> <fieldref id="{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}" name="Modified" hidden="TRUE"> <fieldref id="{822c78e3-1ea9-4943-b449-57863ad33ca9}" name="Modified_x0020_By" hidden="FALSE"> <fieldref id="{4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb}" name="Created_x0020_By" hidden="FALSE">

So that solved it for the content types - if I added those content types to document libraries, there was no more issue of checking documents from office 2003. However, if you are adding the content types to the document library using either a feature (elements file with ContentTypeBinding) or using schema.xml, an incorrect character or binding in the xml files may also trigger the same issue. so beware!

No comments: