0

I have the following query which returns some of the recurring events but not all. The query is not returning the items in the correct order, nor is it returning the items after today's date.

How can I modify the query below to return events that occur after today and in ascending order?

<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>521dx906-1zdc-429d-b4c8-185fafa88029</listName>
      <query>
        <Query>
          <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">2019-08-16T14:29:03.361Z</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>
        </QueryOptions>
      </queryOptions>
    </GetListItems>
  </soap:Body>
</soap:Envelope>

My calendar contains the recurring "Merchandising Notes Posted!" event on the following days:

  • 8/17
  • 8/24
  • 8/31
  • etc...

enter image description here

However, just two "Merchandising Notes Posted!" events are being returned from the query above, and one's from last month!

  • 7/27
  • 8/17

enter image description here

Edit: The query has been updated:

<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>521dx906-1zdc-429d-b4c8-185fafa88029</listName>
      <query>
        <Query>
          <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">
                  <Now />
                </Value>
              </DateRangesOverlap>
            </And>
          </Where>
          <OrderBy>
            <FieldRef Name='EventDate' Ascending='True' />
          </OrderBy>
        </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>
        </QueryOptions>
      </queryOptions>
    </GetListItems>
  </soap:Body>
</soap:Envelope>
2
+50

Put below code instead of the date time value.

 <DateRangesOverlap>
            <FieldRef Name="EventDate" />
            <FieldRef Name="EndDate" />
            <FieldRef Name="RecurrenceID" />
            <Value Type="DateTime"><Now /></Value>
          </DateRangesOverlap>

And for ordering put <OrderBy><FieldRef Name='EventDate' Ascending='True' /></OrderBy> after </Where> Try different options mentioned in below link.

Remove the <viewfields>.

Recurring Events

  • When I try that, the service only returns two events, the first with ows_EventDate='2019-05-23T00:00:00Z' and the second ows_EventDate='2019-07-27T00:00:00Z'. Any idea why it only returns two events!? There should be an event for every week until 2038 (according to the event's ows_EndDate='2038-09-11T23:59:00Z')! – user1477388 Aug 21 at 18:29
  • if you use <Now /> then it will return the events of next two years from today's date. – dhruvil29 Aug 21 at 18:31
  • Check this link for more details and to check how this options works. sharepointnadeem.com/2015/05/… – dhruvil29 Aug 21 at 18:41
  • When I use <Now /> it returns 18 items but only 1 item from my "Merchandising" series which occurs every Saturday. The one that it returns has ows_EventDate='2019-07-27T00:00:00Z' which is in the past. Why would it be returning a past event when we asked for events after <Now />? – user1477388 Aug 21 at 19:22
  • Can you please post the new query you are using ?? I verified this with my list and it's giving expected output – dhruvil29 Aug 21 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.