Note: This question is similar to an existing, unanswered question (CAML OrderBy for SharePoint Recurring Calendar Event).
How can I use the Lists.asmx web service to retrieve recurring events that occur today or later?
I am providing the <CalendarDate>2019-06-25T15:55:04.108Z</CalendarDate>
parameter when sending the request to the /_vti_bin/Lists.asmx
web service, yet I'm still receiving events from the past (as shown in the screenshot below)!
This is the XML response (screenshot). Notice how the event dates are before today even though "CalendarDate" is specified as "2019-06-25":
This is the XML payload sent with the request:
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<listName>{ my list GUID }</listName>
<query>
<Query>
<OrderBy>
<FieldRef Ascending='TRUE' Name='EventDate' />
</OrderBy>
<Where>
<And>
<Eq>
<FieldRef Name="fRecurrence" />
<Value Type="Boolean">1</Value>
</Eq>
<DateRangesOverlap>
<FieldRef Name="EventDate" />
<FieldRef Name="EndDate" />
<FieldRef Name="RecurrenceID" />
<Value Type='DateTime'>
<Year/>
</Value>
</DateRangesOverlap>
</And>
</Where>
</Query>
</query>
<viewFields>
<ViewFields>
<FieldRef Name="Category" />
<FieldRef Name="Location" />
</ViewFields>
</viewFields>
<queryOptions>
<QueryOptions>
<ViewAttributes Scope="RecursiveAll" />
<RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion>
<DateInUtc>TRUE</DateInUtc>
<ExpandRecurrence>TRUE</ExpandRecurrence>
<CalendarDate>2019-06-25T15:55:04.108Z</CalendarDate>
<RecurrenceOrderBy>TRUE</RecurrenceOrderBy>
</QueryOptions>
</queryOptions>
<rowLimit>20</rowLimit>
</GetListItems>
</soap:Body>
</soap:Envelope>
Edit: The following is an example of an event that is not being returned by the query above.
Year
does not honour the CalendarDate
property - it returns previous events that happened within a year from current date and future events a year from current date.
Use <Value Type='DateTime'><Now /></Value>
in the DateRangesOverlap
and remove the CalendarDate
to retrieve recurring events that occur today or later
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With