Code Play and Learn

How Get Calendar recurrent events by CSOM from SharePoint 2013.

Advertisements

Hi I am Going to Explain you here how to get Recurrence Event From your Sharepoint Calender List Using Client Object model(CSOM) Getting Recurrence Event From List using Server OM  is bit eassy as Below

SPQuery query = new SPQuery();
query.ExpandRecurrence = true;

query.Query = String.Format(
"" +
"" +
"" +
"",
Fields.StartDate,
Fields.EndDate,
Fields.RecurrenceId,
orderBy);

Now Coming on CSOM-

But Nothing is impossible…….. Final way is call old-fashion List.asmx.

  function GetItemsFromCalendarAsmx () {
wsURL = webUrl + “_vti_bin/Lists.asmx”;
var xmlCall =
“<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;
};

hope you GET expected Solutions

Happy Coding Thanks SPS

Advertisements