How Get Calendar recurrent events by CSOM from SharePoint 2013.

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-

  • The problem with recurrence is that there is only a single list item. The recurrence information is stored inside a hidden field of that list item called ‘RecurrenceData’ as XML that gets calculated out. Unfortunately Microsoft.SharePoint.Client.CamlQuery doesn’t have the properties that SPQuery does in the server object model to transform this information.
  • What is a little more frustrating is that the new OData operations through REST do not support the DateTimeRangesOverlap operator or “querying as to whether a date time falls inside a recurrent date time pattern

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

  • There was a way to call Lists.asmx in versions before 2013 using SOAP and pass an entire XML message which would allow you to use the DateRangesOverlap filter in the query, and allow you to pass QueryOptions that would include ExpandRecurrence and CalendarDate, but it was flaky trying to pass an actual datetime value for CalendarDate as the value to check if the event overlaps with.
  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

One thought on “How Get Calendar recurrent events by CSOM from SharePoint 2013.

  1. hi can you please tell me how to fetch list item using date filter from sharepoint clalander where start date is a reoccuring event.

    eg start date feb 16 time 4PM to end date 16feb 6PM
    start date 17feb 4PM to 17feb 6PM.

    now i want to show data (name of the person) who is coimn in between this current date and time, i.e if today is 16feb time 5PM then first name should come and if time is 7PM it should not come.

    filter data on daily basis.

    Like

Leave a Reply to Mandeep Kumar Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s