Problems with the start time field and the content query web part
This is one that I came across today when I was trying to use the content query web part to show a list of events in calendars and getting it to include the start date of the event. As always, I used Heather Solomon’s blog post on customising the CQWP as a point of reference, and I found that when I got to the end the date was not showing, there was no value being returned.
Basically the issue is this – when you look at the site column “Start time” that is used in the event content type you see the internal name of the field is “StartDate”, but when I put this into the CQWP I got no value back at all. After a chat with a couple of people I work with (particular thanks to Ishai) who suggested I grab the U2U CAML creator and see what I could get out of that with the same query – lucky for me this gave me the solution immediately. When I saw the tool build the CAML for the query, I saw it was using “EventDate” as the internal field, not “StartDate” as I had first been lead to believe. I swapped that into my content query web part and things suddenly came to life and all was good.
The issue here is that if you look at the schema.xml file for the calendar list, you will see in it’s fields it refers to the start time field with an internal name of “EventDate”. It is definitely talking about the same field because the ID attribute is the same as the “StartDate” field in the event content type. I’m not quite sure why these are different (or even how everything works with them being different because I thought the internal names all had to match, but apparently that was wrong) but that was it. Here are the two field tags:
From “schema.xml”:
<Field Type=”DateTime” ID=”{64cd368d-2f95-4bfc-a1f9-8d4324ecb007}” Name=”EventDate” DisplayName=”$Resources:core,Start_Time;” Format=”DateTime” Sealed=”TRUE” Required=”TRUE” FromBaseType=”TRUE” Filterable=”FALSE” FilterableNoRecurrence=”FALSE” SourceID=”http://schemas.microsoft.com/sharepoint/v3″ StaticName=”EventDate”>
From the content type schema:
<Field ID=”{64cd368d-2f95-4bfc-a1f9-8d4324ecb007}” Name=”StartDate” SourceID=”http://schemas.microsoft.com/sharepoint/v3″ StaticName=”StartDate” Group=”Base Columns” Type=”DateTime” Format=”DateTime” DisplayName=”Start Time” Required=”TRUE” Customization=”">
So if you find yourself getting stuck with this, make sure you are using the right internal name and you should be fine.




No trackbacks yet.