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!

Using the Today token in a CAML query

I just noticed today that the CAML creator application that I am using (by U2U) does not handle the today token properly (at least the version I have).
The Today token is used in views, when you want to filter on a date based on the current date. For example, if you want to set up a view that shows future events you set the filter on start date > "[Today]".

However, in CAML, you cannot use "[Today]" - the square brackets cause the query to break. Instead, you use "<Today />".
For example:
<Where><Geq><FieldRef Name='EventDate' /><Value Type='DateTime'><Today /></Value></Geq></Where>

Tuesday, June 02, 2009

Read bits of my book in google

I just discovered that Google has bits of my sharepoint book that you can see for free- including the section on keyboard shortcuts (which I think is useful to print and put on the wall). Take a look (and feel free to write a review either there in google or here in the comments). The link is