Frage

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);
                    });
                }
            });
        });
War es hilfreich?

Lösung

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>

Andere Tipps

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);
        });
    }
});

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>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top