I made the move from the world of Java, back to the world of Windows not too long ago, after a hiatus of about 12 years. Some things are good, I’m enjoying some aspects of C#, but others are driving me BONKERS! For instance, I work on a public SharePoint site, and we are using a SharePoint Calendar and/or Events list. You can query things from SharePoint lists with an XML based language called CAML, it lets you right SQLesque statements to select and filter data coming back from the list. Now because this is an Events list, there are a couple of extensions over ordinary lists, one of which is recurring events, this makes sense. When you get data back from these recurring events you don’t want to use the ID field of the item, it will be the same for every instance of a recurring event….ok, still kinda makes sense…a little… When you make your query, there are a couple of fields that you need to set in order for it to work right with recurring events, one is SPQuery.ExpandRecurrence must be set to true, this seems logical after all the other assumptions we’ve allowed, and you just set the date on the calendar list itself, ok, still good. So I set the query property of the SPQuery to properly select all the data I want to show, and everything is working just hunky dory. Well, everything save one thing. For all those recurring events, of which I have a TON, RecurrenceID is equal to ID, the whole recurrence magic just isn’t happening. So I look through everything, all the tutorials, StackOverflow, what have you, and nothing. The pages on MSDN are little more than what I would expect to see in an empty Javadoc, no help there. So I step back and try to figure out what might be inferred in all the articles I’ve found….well, they all have a line in their CAML query
<DateRangesOverlap><FieldRef Name=”StateDate”/><FieldRef Name=”EndDate”/><FieldRef Name=”RecurrenceID”/><Value Type=”DateTime”></Value></DateRangesOverlap>
No one really says what exactly this is supposed to do, but looking at it, knowing that this in basically in your queries “where” clause, it looks like its filtering the data by the current date, or some date or other.
Well, if it really did that I wouldn’t be having this rant. What this line does is make it so that the RecurrenceID field actually gets assigned the correct value if you’ve done everything else right. I didn’t really get a clue about this from any of the articles I read, and especially not from anything on MSDN, the only clue was from sitting quietly and wondering what was different…and AFTER finding out, wondering quite loudly WHO THE HELL THOUGHT THIS WAS A GOOD IDEA!!???
I seem to be doing that a lot lately concerning SharePoint, and the new integrated inventory view on EveOnline…