Get Single and Recurring Calendar Events without jQuery

When I first began working with SharePoint calendars, I quickly realized how difficult it was to work with recurring events. Unfortunately there is not a native way to collect the recurring events- only be done using the SharePoint web service via SOAP or REST. SharePoints’ own CSOM does not provide a mechanism to do so.

The existing methods to get recurring events out there typically involve using a library such as SP Services. I instinctively dislike using large libraries with dependencies, so I decided to create my own code that has no dependencies.

The code below will collect all recurring events from a SharePoint calendar list, as well as parse the returned XML into an array of JavaScript objects. Each object is a recurring item from the calendar list. I am using SOAP to query SharePoints’ web service to gather the data.

There are two parameters to call the function- the name of the calendar, and whether or not you would like to make the Ajax call asynchronous or not.

After calling the function above, it will return an array called events that contains all the recurring data as seen here:

There are zero dependencies in use, you can simply copy and paste the code, insert the name of your calendar list, and it will return an array of all the recurring calendar events. This is obviously probably not the way it would be done in a production environment, but it gives you the raw tool you need in order to grab the desired data and transform it into a format you can work with for further use.

This code was taken out of a portion of the SP Calendar Pro library I set up on GitHub.

Collect Single and Recurring Events

If you would like to collect both the single and recurring events from a SharePoint calendar, the code below will handle that:

The only difference between this code and the first one is in the CAML query.