Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

This is the chunch of code that I am working with. I am trying to get only the events (normal/all day/recurring) to show, and it is returning all items for the whole week. Any ideas?

            $(document).ready(function(){
            $().SPServices({
                operation: "GetListItems",
                async: false,
                listName: "Calendar",
                CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
                CAMLQuery: '<Query>' +
                            '<Where>' +
                                '<DateRangesOverlap>' +
                                '<FieldRef Name="EventDate" />' +
                                '<FieldRef Name="EndDate" />' +
                                '<FieldRef Name="RecurrenceID" />' +
                                '<Value Type="DateTime">' +
                                    '<Today />' +
                                '</Value>' +
                                '</DateRangesOverlap>' +
                            '</Where>' +
                            '</Query>',
                completefunc: function (xData, Status){
                    $(xData.responseXML).SPFilterNode("z:row").each(function(){
                        var lihtml = "<li>" + $(this).attr("ows_Title") + "</li>";
                        $("#calendarItems").append(lihtml);
                    });
                }
            });
        });
share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

Sorry for not getting back to you sooner. I was in training and then extremely ill the last 30ish hours.

Take a look at this post by Josh McCarty: http://joshmccarty.com/2011/11/sharepoint-jquery-and-fullcalendar%E2%80%94now-with-spservices/, wherein he followed some details I posted in this discussion on the SPServices codeplex site: http://spservices.codeplex.com/discussions/254560

I'm still not feeling 100% and have lots of catchup to do on my own job. If you're still struggling with this on Monday, let me know and I'll try to take a deeper look.

Blessings,

Jim Bob

Update: There are a couple option Query Options you need to add to get the expanded data from recurrent dates. Give the following a try and let me know how close you get.

<script type="text/javascript">

    $(document).ready(function(){
        $().SPServices({
            operation: "GetListItems",
            async: false,
            listName: "Calendar",
            CAMLViewFields: "<ViewFields>" +
                    "<FieldRef Name='Title' />" +
                    "<FieldRef Name='EventDate' />" +
                    "<FieldRef Name='EndDate' />" +
                    "<FieldRef Name='Location' />" +
                    "<FieldRef Name='Description' />" +
                    "<FieldRef Name='fRecurrence' />" +
                    "<FieldRef Name='RecurrenceData' />" +
                    "<FieldRef Name='fAllDayEvent' />" +
                "</ViewFields>",
            CAMLQuery: "<Query>" +
                    "<Where>" +
                        "<DateRangesOverlap>" +
                            "<FieldRef Name='EventDate' />" +
                            "<FieldRef Name='EndDate' />" +
                            "<FieldRef Name='RecurrenceID' />" +
                            "<Value Type='DateTime'>" +
                                "<Today />" +
                            "</Value>" +
                        "</DateRangesOverlap>" +
                    "</Where>" +
                    "<OrderBy>" +
                        "<FieldRef Name='EventDate' />" +
                    "</OrderBy>" +
                "</Query>",
            CAMLQueryOptions: "<QueryOptions>" +
                    "<RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion>" +
                    "<ExpandRecurrence>TRUE</ExpandRecurrence>" +
                "</QueryOptions>",
            completefunc: function (xData, Status){
                    $(xData.responseXML).SPFilterNode("z:row").each(function(){
                        var lihtml = "<li>" + $(this).attr("ows_Title") + "</li>";
                        $("#calendarItems").append(lihtml);
                    });
                }
            });
        });

</script>
share|improve this answer
    
Jim, To no avail.... I followed that tutorial for a bit, but didn't integrate the fullcalendar plugin because we don't need that. I am still not able to get this to function correctly. –  Brenton Pierce Apr 16 '12 at 13:11
    
Right. The fullcalendar implementation isn't as important as how to pull the dates. Updating answer above. –  Jim Bob Howard Apr 17 '12 at 14:35
    
Thanks again!!! –  Brenton Pierce Apr 17 '12 at 16:21
add comment

The last example code is missing the CAMLOptions option that tells SharePoint to expand recurring events. Otherwise it should produce the desired results. I tested this and it showed all events that overlap today or start today. It also showed an all day event for tomorrow, which is probably a time zone setting issue.

$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Calendar",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='EventDate' /><FieldRef Name='EndDate' /><FieldRef Name='Location' /><FieldRef Name='Description' /><FieldRef Name='fRecurrence' /><FieldRef Name='RecurrenceData' /><FieldRef Name='RecurrenceID' /><FieldRef Name='fAllDayEvent' /></ViewFields>",
    CAMLQuery: "<Query><CalendarDate><Today /></CalendarDate><Where><DateRangesOverlap><FieldRef Name='EventDate' /><FieldRef Name='EndDate' /><FieldRef Name='RecurrenceID' /><Value Type='DateTime'><Today /></Value></DateRangesOverlap></Where><OrderBy><FieldRef Name='EventDate' /></OrderBy></Query>",
    CAMLOptions: "<QueryOptions><CalendarDate><Today /></CalendarDate><RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion><ExpandRecurrence>TRUE</ExpandRecurrence><DateInUtc>FALSE</DateInUtc></QueryOptions>",
    completefunc: function (xData, Status){
        $(xData.responseXML).SPFilterNode("z:row").each(function(){
            var lihtml = "<li>" + $(this).attr("ows_Title") + "</li>";
            $("#calendarItems").append(lihtml);
        });
    }
});
share|improve this answer
add comment

None of the solutions above worked for me in SP 2013 but this did.

<Where>
<Or>
    <Or>
        <And>
            <Eq>
                <FieldRef Name='fAllDayEvent' />
                <Value Type='AllDayEvent'>1</Value>
            </Eq>
            <Geq>
                <FieldRef Name='EndDate' />
                <Value Type='DateTime'>
                    <Today />
                </Value>
            </Geq>
        </And>
        <DateRangesOverlap>
          <FieldRef Name='EventDate' />
          <FieldRef Name='EndDate' />
          <FieldRef Name='RecurrenceID' />
          <Value Type='DateTime' IncludeTimeValue='TRUE'>
            <Today />
          </Value>
        </DateRangesOverlap>
    </Or>
   <Geq>
      <FieldRef Name='EventDate' />
      <Value Type='DateTime' IncludeTimeValue='TRUE'>
         <Today />
      </Value>
   </Geq>
</Or>
</Where>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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