Question

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>
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top