4

Is it possible to get a list of events (with recurring events expanded) out of Sharepoint's Calendar using the Web Service exposed through Lists.aspx?

This is evidently possible if you are using C# or VB, as described here using a snippet like this:

SPQuery query = new SPQuery();
query.ExpandRecurrence = true;
query.Query = "<Where><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" /><FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Month /></Value></DateRangesOverlap></Where>";

I am trying to do the same using plain XML via cURL with this query:

<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>{my guid goes here}</listName>
<query>
    <Query xmlns="">
    <Where>
    <DateRangesOverlap>
      <FieldRef Name="EventDate" />
      <FieldRef Name="EndDate" />
      <FieldRef Name="RecurrenceID" />
      <Value Type="DateTime"><Month/></Value>
   </DateRangesOverlap>
    </Where>
    </Query>
</query>
<queryOptions>
    <QueryOptions>
    <ExpandRecurrence>TRUE</ExpandRecurrence>
    </QueryOptions>
</queryOptions>

This kinda works - it gets all the list items, but recurring items are not expanded. The key seems to be the ExpandRecurrence property. Surprisingly, Google does not seem to have a lot to say on the matter beyond a couple of blog posts. Scouring the web, I've read a few comments indicating that the ExpandRecurrence property does not work, but others say it works fine and nothing I've read has struck me as definitive.

Has anybody tried this and gotten it to work without using C# or VB - just straight XML?

allclaws
  • 5,575
  • 8
  • 30
  • 27
  • No. I never figured it out. It *seems* like the ExpandRecurrence simply must be done server-side. Depending on your situation, you may be able to create a Web Service wrapper that mimics the normal Calendar web service, but explicitly handles the ExpandRecurrence flag. That's my only guess so far. – allclaws Apr 28 '09 at 12:40
  • -1 this post has the wrong accepted answer – Christophe Oct 04 '13 at 17:40

5 Answers5

5

Finally got this to work correctly and return all recurrent events on a SharePoint Calendar. Here is the XML for the Web Service Query:

<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<listName>{your GUID goes here}</listName>
<query>
 <Query>
  <Where>
   <DateRangesOverlap>
    <FieldRef Name=\"EventDate\" />
    <FieldRef Name=\"EndDate\" />
    <FieldRef Name=\"RecurrenceID\" />
    <Value Type='DateTime'><Year/></Value>
   </DateRangesOverlap>
  </Where>
 </Query>
</query>
<queryOptions>
 <QueryOptions>
  <ExpandRecurrence>TRUE</ExpandRecurrence>
 </QueryOptions>
</queryOptions>
</GetListItems>

The key was not only setting the ExpandRecurrence option to true - you also have to include the value in the DateRangeOverlap to Year.

user557264
  • 51
  • 1
  • 2
2

I think I've had a similar issue where it was just returning the items in a list and not actually expanding the recurring items (i.e. an item marked a occurring every Monday only showed as a single record instead of multiple records).

Apparently version 12.0.0.6421 (2007 SP1) does not expand items even when you tell it do via the web service APIs. When we applied the latest cumulative updates (Aug 2011), it worked as we expected (i.e. it would return the multiple scheduled entries each Monday).

Here was the code I had that worked once we applied CUs:

    Query for ndQuery:
--------------------
<Where>
<DateRangesOverlap>
<FieldRef Name=""EventDate"" /><FieldRef Name=""EndDate"" /><FieldRef Name=""RecurrenceID"" />
<Value Type=""DateTime""><Month/></Value>
</DateRangesOverlap>
</Where>>
<OrderBy><FieldRef Name='ID' /></OrderBy>

query options for ndQueryOptions:
-----------------------------------------------
<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
<DateInUtc>TRUE</DateInUtc>
<ViewAttributes Scope=\"Recursive\" />
<RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion>
<ExpandRecurrence>True</ExpandRecurrence>
<CalendarDate>2011-10-16T00:00:00Z</CalendarDate>
<RecurrenceOrderBy>TRUE</RecurrenceOrderBy>
<ViewAttributes Scope=\"RecursiveAll\"/>

Web service call:
------------------------
XmlNode results = wsList.GetListItems("Events", String.Empty, ndQuery, ndViewFields, String.Empty, ndQueryOptions, "F43559AF-C643-4FF3-AAA3-77471A2D1979");
Chad
  • 141
  • 1
  • 2
0

The way I would track down this problem would be to use something like TcpTrace (http://www.pocketsoap.com) to look at the XML packets being sent. Then it is a matter of making sure the hand-crafted XML packet looks the same. I'm hoping that when you see the XML packet, the difference should be obvious. Then you can update this question with the answer.

Tommy Hui
  • 1,306
  • 6
  • 9
0

Yes you can split the recurring events in sharepoint calendar and can download from a list for a particular period of time.

I have created a custom dll for the same.

https://github.com/shafeequealipt/Share-Point-Recurrance-event-splitter

-2

Nope is not possible. You would need to use the SP Object model via, for example the SPQuery object. But that would mean that you would have to run that code directly on the sharepoint server, instead of calling in from a client.

Please see this post of mine; http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/3c399768-c492-4d7e-8f6e-fa304ed03131

Obelix
  • 708
  • 11
  • 24
  • 3
    This is incorrect. The answers below are correct. I realize this is an old post, but just in case anyone else stumbles across it, use the solutions below. – Robbert Feb 19 '15 at 23:06
  • That is definitely possible from the client side. Using the Lists web service, as described in other answers below. – pholpar Jan 18 '17 at 10:38