4

Using Client context how to get all recursive Events...

 ClientContext clientContext = new ClientContext(siteUrl);
            clientContext.Credentials = cred;
            var oList = clientContext.Web.Lists.GetByTitle("Upcoming Events");

            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View><Query><Where>" +
                              "<DateRangesOverlap><FieldRef Name=\"EventDate\" />" +
                              "<FieldRef Name=\"EndDate\" />" +
                              "<FieldRef Name=\"RecurrenceID\"/>" +
                              "<Value Type=\"DateTime\"><Month /></Value></DateRangesOverlap>" +
                              "</Where></Query></View>";


            ListItemCollection collListItem = oList.GetItems(camlQuery);

            clientContext.Load(collListItem);

            clientContext.ExecuteQuery();
  • what all have you tried? – Akshay Randive Jun 12 '17 at 6:38
  • I added my Code please check it.. – Sarika Koli Jun 12 '17 at 6:40
  • query looks correct to me what is the error that you see browser/ developer console? – Akshay Randive Jun 12 '17 at 7:05
  • There is no Error..It display Event.but I want all recursive Event with all repeating occurrence.. – Sarika Koli Jun 12 '17 at 7:08
  • can you try <Now/> instead of <Month/> and try? (I know you may not want to get all but i have faced same issue and had to go with "Now" and then filtering data) – Akshay Randive Jun 12 '17 at 7:35
3

I think thats not possible using Client object model using CAML queries. You can try this solution instead and see if it works

function GetItemsFromCalendarAsmx () {
wsURL = webUrl + “_vti_bin/Lists.asmx”;
var xmlCall =
“<soap:Envelope xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance&#8217; xmlns:xsd=’http://www.w3.org/2001/XMLSchema&#8217; xmlns:soap=’http://schemas.xmlsoap.org/soap/envelope/’&gt; <soap:Body>” +
“<GetListItems xmlns=’http://schemas.microsoft.com/sharepoint/soap/’>&#8221; +
“<listName>” + calendarGuid + “</listName>” +
“<query>” +
“<Query>” +
“<Where>” +
“<DateRangesOverlap>” +
“<FieldRef Name=\”EventDate\” />” +
“<FieldRef Name=\”EndDate\” />” +
“<FieldRef Name=\”RecurrenceID\” />” +
“<Value Type=’DateTime’><Year/></Value>” +
“</DateRangesOverlap>” +
“</Where>” +
“</Query>” +
“</query>” +
“<queryOptions>” +
“<QueryOptions>” +
“<ExpandRecurrence>TRUE</ExpandRecurrence>” +
“</QueryOptions>” +
“</queryOptions>” +
“</GetListItems>” +
“</soap:Body></soap:Envelope>”;
var result = [];
$.ajax({
url: wsURL,
type: “POST”,
dataType: “xml”,
async: false,
data: xmlCall,
complete: function (xData, status) {
Core.LogMessage(“Core.GetItemsFromCalendarAsmx-> url: ” + wsURL + ” status: ” + status);
if (status === “success”) {
var root = $(xData.responseText);
root.find(“listitems”).children().children().each(function () {
$this = $(this);
var ids = $this.attr(“ows_UniqueId”).split(“;”);
var rec = $this.attr(“ows_fRecurrence”);
result.push({
“StartTime”: $this.attr(“ows_EventDate”),
“EndTime”: $this.attr(“ows_EndDate”),
“Title”: $this.attr(“ows_Title”),
“Recurrence”: (rec === “1” ? true : false),
“Description”: Core.HtmlDecode($this.attr(“ows_Description”)),
“Guid”: ids[1],
“Id”: ids[0],
});
});
}
},
contentType: “text/xml; charset=\”utf-8\””
});
return result;
};

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.