How can we help you today?

Workaround for Showing Occurrences of Recurring Event in ShortPoint Events Element


Problem


You have a recurring event in your event list:



When you connect above list to Events ShortPoint element, you would not see the recurring event occurrences:



Reason


Recurrences have been handled differently in SharePoint and requesting all list items of calendar does not return all occurrences of events if its recurring event. 


Solution


Step 1: Add Events ShortPoint element


In the page where you would want to add Events ShortPoint, add ShortPoint and select Events



Step 2: Connect using REST API Connection


Go to Connect Tab and select REST API Connection Type



In REST API URL, provide below URL:


<https://your-site>/_api/web/lists/getbytitle('<Events List Title>')/items?$select=*,Duration,RecurrenceData


<https://your-site>: Replace with your site URL (for example https://contoso.sharepoint.com)

<Events List Title>: Replace with title of your events list (for example Events)


Example URL: https://shortpoint.sharepoint.com/_api/web/lists/getbytitle('Calendar')/items?$select=*,Duration,RecurrenceData


Step 3: Use custom mapping to expand the recurrences of recurring event



Enable the Advanced Mapping and in Map Results and use the code given in below options as per your need:


OPTION 1: Show all events


var spEventsParser = { parseEvents: function (e, t, a) { for (var n = [], r = 0; r < e.length; r++)n = n.concat(this.parseEvent(e[r], t, a)); return n }, formatString: function (e) { var t = e.split("'"); return e = t.join(""), t = e.split('"'), e = t.join(""), t = e.split("="), e = t.join(" "), e.trim(), e.split(" ") }, parseDate: function (e, t) { if ("string" == typeof e) { if (!t) return new Date(e); if (e.lastIndexOf("Z") == e.length - 1) { var a = e.substring(0, e.length - 1); return new Date(a) } } return e }, parseEvent: function (e, t, a) { if (e.fRecurrence) { t = t || this.parseDate(e.EventDate, e.fAllDayEvent), a = a || this.parseDate(e.EndDate, e.fAllDayEvent); var n = [], r = ["su", "mo", "tu", "we", "th", "fr", "sa"], D = ["first", "second", "third", "fourth"], s = 0, i = 0; if (-1 != e.RecurrenceData.indexOf("<repeatInstances>") && (s = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<repeatInstances>") + 17), s = parseInt(s.substring(0, s.indexOf("<")))), -1 != e.RecurrenceData.indexOf("<daily ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<daily ")); f = f.substring(7, f.indexOf("/>") - 1); var o = this.formatString(f); if (-1 != o.indexOf("dayFrequency")) for (var g = parseInt(o[o.indexOf("dayFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent); c;) { if (i++ , new Date(d).getTime() >= t.getTime()) { var u = new Date(d); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(d), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } d.setDate(d.getDate() + g), (new Date(d) > a || s > 0 && i >= s) && (c = !1) } else -1 != o.indexOf("weekday") && (e.RecurrenceData = e.RecurrenceData + "<weekly mo='TRUE' tu='TRUE' we='TRUE' th='TRUE' fr='TRUE' weekFrequency='1' />") } if (-1 != e.RecurrenceData.indexOf("<weekly ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<weekly ")); f = f.substring(8, f.indexOf("/>") - 1); for (var o = this.formatString(f), g = parseInt(o[o.indexOf("weekFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), v = d.getDay(); c;) { for (var h = v; 7 > h; h++)if (-1 != o.indexOf(r[h]) && (s > i || 0 == s) && (i++ , new Date(d).getTime() >= t.getTime())) { var y = new Date(d); y.setDate(y.getDate() + (h - v)); var u = new Date(y); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(y), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } d.setDate(d.getDate() + (7 * g - v)), v = 0, (new Date(d) > a || s > 0 && i >= s) && (c = !1) } } if (-1 != e.RecurrenceData.indexOf("<monthly ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<monthly ")); f = f.substring(9, f.indexOf("/>") - 1); for (var o = this.formatString(f), g = parseInt(o[o.indexOf("monthFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), w = parseInt(o[o.indexOf("day") + 1]); c;) { if (i++ , new Date(d).getTime() >= t.getTime()) { var y = new Date(d); if (y.setDate(w), y.getMonth() == d.getMonth()) { var u = new Date(y); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(y), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } } d.setMonth(d.getMonth() + g), (new Date(d) > a || s > 0 && i >= s) && (c = !1) } } if (-1 != e.RecurrenceData.indexOf("<monthlyByDay ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<monthlyByDay ")); f = f.substring(14, f.indexOf("/>") - 1); for (var o = this.formatString(f), g = parseInt(o[o.indexOf("monthFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), O = o[o.indexOf("weekdayOfMonth") + 1], x = new Date; c;) { if (i++ , new Date(d).getTime() >= t.getTime()) { var y = new Date(d); if (y.setDate(1), -1 != o.indexOf("weekday")) if (0 == y.getDay() ? y.setDate(y.getDate() + 1) : 6 == y.getDay() && y.setDate(y.getDate() + 2), "last" == O) { for (; y.getMonth() == d.getMonth();)x = new Date(y), y.setDate(5 == y.getDay() ? y.getDate() + 3 : y.getDate() + 1); y = new Date(x) } else for (var h = 0; h < D.indexOf(O); h++)y.setDate(5 == y.getDay() ? y.getDate() + 3 : y.getDate() + 1); else if (-1 != o.indexOf("weekend_day")) if (0 != y.getDay() && 6 != y.getDay() && y.setDate(y.getDate() + (6 - y.getDay())), "last" == O) { for (; y.getMonth() == d.getMonth();)x = new Date(y), y.setDate(0 == y.getDay() ? y.getDate() + 6 : y.getDate() + 1); y = new Date(x) } else for (var h = 0; h < D.indexOf(O); h++)y.setDate(0 == y.getDay() ? y.getDate() + 6 : y.getDate() + 1); else if (-1 != o.indexOf("day")) if ("last" == O) { var y = y.setMonth(y.getMonth() + 1); y.setDate(0) } else y.setDate(y.getDate() + D.indexOf(O)); else { for (var h = 0; h < r.length; h++)-1 != o.indexOf(r[h]) && y.setDate(y.getDay() > h ? y.getDate() + (7 - (y.getDay() - h)) : y.getDate() + (h - y.getDay())); if ("last" == O) { for (; y.getMonth() == d.getMonth();)x = new Date(y), y.setDate(y.getDate() + 7); y = new Date(x) } else for (var h = 0; h < D.indexOf(O); h++)y.setDate(y.getDate() + 7) } if (y.getMonth() == d.getMonth()) { var u = new Date(y); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(y), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } } d.setMonth(d.getMonth() + g), (new Date(d) > a || s > 0 && i >= s) && (c = !1) } } if (-1 != e.RecurrenceData.indexOf("<yearly ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<yearly ")); f = f.substring(8, f.indexOf("/>") - 1); for (var o = this.formatString(f), g = parseInt(o[o.indexOf("yearFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), p = parseInt(o[o.indexOf("month") + 1]) - 1, w = parseInt(o[o.indexOf("day") + 1]); c;) { var y = new Date(d); if (y.setMonth(p), y.setDate(w), new Date(d).getTime() <= y.getTime() && (i++ , new Date(d).getTime() >= t.getTime())) { var u = new Date(y); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(y), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } d.setFullYear(d.getFullYear() + g), (new Date(d) > a || s > 0 && i >= s) && (c = !1) } } if (-1 != e.RecurrenceData.indexOf("<yearlyByDay ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<yearlyByDay ")); f = f.substring(13, f.indexOf("/>") - 1); for (var o = this.formatString(f), g = parseInt(o[o.indexOf("yearFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), p = parseInt(o[o.indexOf("month") + 1]) - 1, O = o[o.indexOf("weekdayOfMonth") + 1], w = 0, h = 0; h < r.length; h++)-1 != o.indexOf(r[h]) && "true" == o[o.indexOf(r[h]) + 1].toLowerCase() && (w = h); for (; c;) { var y = new Date(d); if (y.setMonth(p), new Date(d).getTime() <= y.getTime() && (i++ , new Date(d).getTime() >= t.getTime())) { y.setDate(1); var E = y.getDay(); if (y.setDate(E > w ? y.getDate() + (7 - E + w) : y.getDate() + (w - E)), "last" == O) for (var x = new Date(y); x.getMonth() == p;)y = new Date(x), x.setDate(x.getDate() + 7); else y.setDate(y.getDate() + 7 * D.indexOf(O)); if (y.getMonth() == p) { var u = new Date(y); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(y), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } } d.setFullYear(d.getFullYear() + g), d.setMonth(p), d.setDate(1), (new Date(d) > a || s > 0 && i >= s) && (c = !1) } } return n } return e.EventDate = new Date(this.parseDate(e.EventDate, e.fAllDayEvent)), e.EndDate = new Date(this.parseDate(e.EndDate, e.fAllDayEvent)), [e] }, cloneObj: function (e) { var t; if (null == e || "object" != typeof e) return e; if (e instanceof Date) return t = new Date, t.setTime(e.getTime()), t; if (e instanceof Array) { t = []; for (var a = 0, n = e.length; n > a; a++)t[a] = this.cloneObj(e[a]); return t } if (e instanceof Object) { t = {}; for (var r in e) e.hasOwnProperty(r) && (t[r] = this.cloneObj(e[r])); return t } throw new Error("Unable to copy obj! Its type isn't supported.") } };
var eventResults = data.d.results;
var parsedArray = spEventsParser.parseEvents(eventResults);
var _ = shortpoint.base.libs._;
var sortedData = _.sortBy(parsedArray, function (a) {
    return a.EventDate ;
});

var $ = shortpoint.$;
currentSite = window.location.protocol + "//" + window.location.host + _spPageContextInfo.webServerRelativeUrl;
TimeZone = {};
 $.ajax({
            url: currentSite + "/_api/Web/RegionalSettings/TimeZone",
            method: "GET",
      async: false,
            headers: { "Accept": "application/json; odata=verbose" },
        }).done(function (response) {
      TimeZone = response.d;
            sortedData.forEach(function(item, index){
        //var d = this.EventDate;
        var localTime = item.EventDate.getTime();
        var localEndTime = item.EndDate.getTime();
        var regionTimeoffset = (TimeZone.Information.Bias + TimeZone.Information.DaylightBias) * 60000;
        var localTimeoffset =  item.EventDate.getTimezoneOffset() * 60000;
        item.EventDate = new Date();
        item.EventDate.setTime(localTime + ((localTimeoffset - regionTimeoffset )));
        item.EndDate = new Date();
        item.EndDate.setTime(localEndTime + ((localTimeoffset - regionTimeoffset )));
        if(item.RecurrenceData != null){
          var instnaceDate = new Date();
          instnaceDate.setTime(localTime );
          item.DisplayId = item.Id + ".0."+ instnaceDate.toISOString().replace(".000Z","Z") ;
        }else{
          item.DisplayId = item.Id;
        }
        });
        return sortedData;
        });   
return sortedData;



OPTION 2: Show events of the next few days


var spEventsParser = { parseEvents: parseEvents, formatString: formatString, parseDate: parseDate, parseEvent: parseEvent, cloneObj: cloneObj }; function parseEvents(e, t, n) { for (var a = [], r = 0; r < e.length; r++)e[r]._SHORTPOINT_Recurring_Event_ID = r, a = a.concat(this.parseEvent(e[r], t, n)); return a; } function formatString(e) { var t = e.split("'"); return e = t.join(""), t = e.split('"'), e = t.join(""), t = e.split("="), (e = t.join(" ")).trim(), e.split(" "); } function parseDate(e, t) { if ("string" == typeof e) { if (t) { if (e.lastIndexOf("Z") == e.length - 1) { var n = e.substring(0, e.length - 1); return new Date(n); } return new Date(e); } return new Date(e); } return e; } function parseEvent(e, t, n) { if (e.fRecurrence) { t = t || this.parseDate(e.EventDate, e.fAllDayEvent), n = n || this.parseDate(e.EndDate, e.fAllDayEvent); var a = [], r = ["su", "mo", "tu", "we", "th", "fr", "sa"], D = ["first", "second", "third", "fourth"], s = 0, i = 0, f = /<windowEnd>(.+)<\/windowEnd>/.exec(e.RecurrenceData) || [], o = (f[0], f[1]); if (o && new Date(o) <= new Date) return []; if (-1 != e.RecurrenceData.indexOf("<repeatInstances>") && (s = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<repeatInstances>") + 17), s = parseInt(s.substring(0, s.indexOf("<")))), -1 != e.RecurrenceData.indexOf("<daily ")) if (x = (x = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<daily "))).substring(7, x.indexOf("/>") - 1), -1 != (y = this.formatString(x)).indexOf("dayFrequency")) for (var c = parseInt(y[y.indexOf("dayFrequency") + 1]), g = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent); g;) { if (i++, new Date(d).getTime() >= t.getTime()) { var u = new Date(d), l = e.Duration % 86400; u.setSeconds(u.getSeconds() + l), (m = this.cloneObj(e)).EventDate = new Date(d), m.EndDate = u, m.fRecurrence = !1, m.Id = e.Id, m.ID = m.Id, a.push(m); } d.setDate(d.getDate() + c), (new Date(d) > n || s > 0 && s <= i) && (g = !1); } else -1 != y.indexOf("weekday") && (e.RecurrenceData = e.RecurrenceData + "<weekly mo='TRUE' tu='TRUE' we='TRUE' th='TRUE' fr='TRUE' weekFrequency='1' />"); if (-1 != e.RecurrenceData.indexOf("<weekly ")) { x = (x = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<weekly "))).substring(8, x.indexOf("/>") - 1); for (var y = this.formatString(x), h = (c = parseInt(y[y.indexOf("weekFrequency") + 1]), g = !0, (d = this.parseDate(e.EventDate, e.fAllDayEvent)).getDay()); g;) { for (var w = h; w < 7; w++) { if (-1 != y.indexOf(r[w]) && (s > i || 0 == s)) if (i++, new Date(d).getTime() >= t.getTime()) (I = new Date(d)).setDate(I.getDate() + (w - h)), (u = new Date(I)).setSeconds(u.getSeconds() + e.Duration), (m = this.cloneObj(e)).EventDate = new Date(I), m.EndDate = u, m.fRecurrence = !1, m.Id = e.Id, m.ID = m.Id, a.push(m); } d.setDate(d.getDate() + (7 * c - h)), h = 0, (new Date(d) > n || s > 0 && s <= i) && (g = !1); } } if (-1 != e.RecurrenceData.indexOf("<monthly ")) { x = (x = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<monthly "))).substring(9, x.indexOf("/>") - 1); y = this.formatString(x), c = parseInt(y[y.indexOf("monthFrequency") + 1]), g = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent); for (var O = parseInt(y[y.indexOf("day") + 1]); g;) { if (i++, new Date(d).getTime() >= t.getTime()) if ((I = new Date(d)).setDate(O), I.getMonth() == d.getMonth()) (u = new Date(I)).setSeconds(u.getSeconds() + e.Duration), (m = this.cloneObj(e)).EventDate = new Date(I), m.EndDate = u, m.fRecurrence = !1, m.Id = e.Id, m.ID = m.Id, a.push(m); d.setMonth(d.getMonth() + c), (new Date(d) > n || s > 0 && s <= i) && (g = !1); } } if (-1 != e.RecurrenceData.indexOf("<monthlyByDay ")) { x = (x = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<monthlyByDay "))).substring(14, x.indexOf("/>") - 1); y = this.formatString(x), c = parseInt(y[y.indexOf("monthFrequency") + 1]), g = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent); for (var v = y[y.indexOf("weekdayOfMonth") + 1], E = new Date; g;) { if (i++, new Date(d).getTime() >= t.getTime()) { if ((I = new Date(d)).setDate(1), -1 != y.indexOf("weekday")) if (0 == I.getDay() ? I.setDate(I.getDate() + 1) : 6 == I.getDay() && I.setDate(I.getDate() + 2), "last" == v) { for (; I.getMonth() == d.getMonth();)E = new Date(I), 5 == I.getDay() ? I.setDate(I.getDate() + 3) : I.setDate(I.getDate() + 1); I = new Date(E); } else for (w = 0; w < D.indexOf(v); w++)5 == I.getDay() ? I.setDate(I.getDate() + 3) : I.setDate(I.getDate() + 1); else if (-1 != y.indexOf("weekend_day")) if (0 != I.getDay() && 6 != I.getDay() && I.setDate(I.getDate() + (6 - I.getDay())), "last" == v) { for (; I.getMonth() == d.getMonth();)E = new Date(I), 0 == I.getDay() ? I.setDate(I.getDate() + 6) : I.setDate(I.getDate() + 1); I = new Date(E); } else for (w = 0; w < D.indexOf(v); w++)0 == I.getDay() ? I.setDate(I.getDate() + 6) : I.setDate(I.getDate() + 1); else if (-1 != y.indexOf("day")) { if ("last" == v) (I = I.setMonth(I.getMonth() + 1)).setDate(0); else I.setDate(I.getDate() + D.indexOf(v)); } else { for (w = 0; w < r.length; w++)-1 != y.indexOf(r[w]) && (I.getDay() > w ? I.setDate(I.getDate() + (7 - (I.getDay() - w))) : I.setDate(I.getDate() + (w - I.getDay()))); if ("last" == v) { for (; I.getMonth() == d.getMonth();)E = new Date(I), I.setDate(I.getDate() + 7); I = new Date(E); } else for (w = 0; w < D.indexOf(v); w++)I.setDate(I.getDate() + 7); } if (I.getMonth() == d.getMonth()) (u = new Date(I)).setSeconds(u.getSeconds() + e.Duration), (m = this.cloneObj(e)).EventDate = new Date(I), m.EndDate = u, m.fRecurrence = !1, m.Id = e.Id, m.ID = m.Id, a.push(m); } d.setMonth(d.getMonth() + c), (new Date(d) > n || s > 0 && s <= i) && (g = !1); } } if (-1 != e.RecurrenceData.indexOf("<yearly ")) { x = (x = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<yearly "))).substring(8, x.indexOf("/>") - 1); y = this.formatString(x), c = parseInt(y[y.indexOf("yearFrequency") + 1]), g = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent); var p = parseInt(y[y.indexOf("month") + 1]) - 1; for (O = parseInt(y[y.indexOf("day") + 1]); g;) { if ((I = new Date(d)).setMonth(p), I.setDate(O), new Date(d).getTime() <= I.getTime()) if (i++, new Date(d).getTime() >= t.getTime()) (u = new Date(I)).setSeconds(u.getSeconds() + e.Duration), (m = this.cloneObj(e)).EventDate = new Date(I), m.EndDate = u, m.fRecurrence = !1, m.Id = e.Id, m.ID = m.Id, a.push(m); d.setFullYear(d.getFullYear() + c), (new Date(d) > n || s > 0 && s <= i) && (g = !1); } } if (-1 != e.RecurrenceData.indexOf("<yearlyByDay ")) { var x; x = (x = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<yearlyByDay "))).substring(13, x.indexOf("/>") - 1); for (y = this.formatString(x), c = parseInt(y[y.indexOf("yearFrequency") + 1]), g = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), p = parseInt(y[y.indexOf("month") + 1]) - 1, v = y[y.indexOf("weekdayOfMonth") + 1], O = 0, w = 0; w < r.length; w++)-1 != y.indexOf(r[w]) && "true" == y[y.indexOf(r[w]) + 1].toLowerCase() && (O = w); for (; g;) { var I; if ((I = new Date(d)).setMonth(p), new Date(d).getTime() <= I.getTime() && (i++, new Date(d).getTime() >= t.getTime())) { I.setDate(1); var m, R = I.getDay(); if (O < R ? I.setDate(I.getDate() + (7 - R + O)) : I.setDate(I.getDate() + (O - R)), "last" == v) for (E = new Date(I); E.getMonth() == p;)I = new Date(E), E.setDate(E.getDate() + 7); else I.setDate(I.getDate() + 7 * D.indexOf(v)); if (I.getMonth() == p) (u = new Date(I)).setSeconds(u.getSeconds() + e.Duration), (m = this.cloneObj(e)).EventDate = new Date(I), m.EndDate = u, m.fRecurrence = !1, m.Id = e.Id, m.ID = m.Id, a.push(m); } d.setFullYear(d.getFullYear() + c), d.setMonth(p), d.setDate(1), (new Date(d) > n || s > 0 && s <= i) && (g = !1); } } return a; } return e.EventDate = new Date(this.parseDate(e.EventDate, e.fAllDayEvent)), e.EndDate = new Date(this.parseDate(e.EndDate, e.fAllDayEvent)), t && n ? new Date(t) <= e.EventDate && new Date(n) >= e.EndDate ? [e] : [] : [e]; } function cloneObj(e) { var t; if (null == e || "object" != typeof e) return e; if (e instanceof Date) return (t = new Date).setTime(e.getTime()), t; if (e instanceof Array) { t = []; for (var n = 0, a = e.length; n < a; n++)t[n] = this.cloneObj(e[n]); return t; } if (e instanceof Object) { for (var r in t = {}, e) e.hasOwnProperty(r) && (t[r] = this.cloneObj(e[r])); return t; } throw new Error("Unable to copy obj! Its type isn't supported."); }

//*******************************/
// Change number of days here:
var numberOfDays = 7;
// Enable Daylight saving time here (change to true)
var enableDayLightSaving = false;
//*******************************/

var today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate());
var endOfPeriod = new Date();
endOfPeriod = new Date(endOfPeriod.setDate(today.getDate() + numberOfDays + 1));
endOfPeriod = new Date(endOfPeriod.getFullYear(), endOfPeriod.getMonth(), endOfPeriod.getDate());

var eventResults = data.d.results;
var parsedArray = spEventsParser.parseEvents(eventResults, null, endOfPeriod);

var _ = shortpoint.base.libs._;

var filteredData = _.filter(parsedArray, function (data) {
    return data.EventDate >= today && data.EventDate <= endOfPeriod;
});
var sortedData = _.sortBy(filteredData, function (a) {
    return a.EventDate;
});
var $ = shortpoint.$;
currentSite = window.location.protocol + "//" + window.location.host + _spPageContextInfo.webServerRelativeUrl;
TimeZone = {};
$.ajax({
    url: currentSite + "/_api/Web/RegionalSettings/TimeZone",
    method: "GET",
    async: false,
    headers: { "Accept": "application/json; odata=verbose" },
}).done(function (response) {
    TimeZone = response.d;
    sortedData.forEach(function (item, index) {
        //var d = this.EventDate;
        var localTime = item.EventDate.getTime();
        var localEndTime = item.EndDate.getTime();
        var regionTimeoffset = (TimeZone.Information.Bias + TimeZone.Information.DaylightBias) * 60000;
        var localTimeoffset = item.EventDate.getTimezoneOffset() * 60000;

        item.EventDate = new Date();
        item.EndDate = new Date();

        if (enableDayLightSaving) {
            item.EventDate.setTime(localTime + (localTimeoffset - regionTimeoffset));
            item.EndDate.setTime(localEndTime + (localTimeoffset - regionTimeoffset));
        } else {
            item.EventDate.setTime(localTime);
            item.EndDate.setTime(localEndTime);
        }

        if (item.RecurrenceData != null) {
            var instnaceDate = new Date();
            instnaceDate.setTime(localTime);
            item.DisplayId = item.Id + ".0." + instnaceDate.toISOString().replace(".000Z", "Z");
        } else {
            item.DisplayId = item.Id;
        }
    });
    return sortedData;
});
return sortedData;



Number of Days: Replace with the number of days you want to show the events for. For example, if you want to show the events of 5 days (including today), you should set it like this: var numberOfDays = 5;

DayLight Saving Time: You can set DST to true or false here. (use this if you see all day events being shown twice)


OPTION 3: Show events of current week


var spEventsParser = { parseEvents: function (e, t, a) { for (var n = [], r = 0; r < e.length; r++)n = n.concat(this.parseEvent(e[r], t, a)); return n }, formatString: function (e) { var t = e.split("'"); return e = t.join(""), t = e.split('"'), e = t.join(""), t = e.split("="), e = t.join(" "), e.trim(), e.split(" ") }, parseDate: function (e, t) { if ("string" == typeof e) { if (!t) return new Date(e); if (e.lastIndexOf("Z") == e.length - 1) { var a = e.substring(0, e.length - 1); return new Date(a) } } return e }, parseEvent: function (e, t, a) { if (e.fRecurrence) { t = t || this.parseDate(e.EventDate, e.fAllDayEvent), a = a || this.parseDate(e.EndDate, e.fAllDayEvent); var n = [], r = ["su", "mo", "tu", "we", "th", "fr", "sa"], D = ["first", "second", "third", "fourth"], s = 0, i = 0; if (-1 != e.RecurrenceData.indexOf("<repeatInstances>") && (s = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<repeatInstances>") + 17), s = parseInt(s.substring(0, s.indexOf("<")))), -1 != e.RecurrenceData.indexOf("<daily ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<daily ")); f = f.substring(7, f.indexOf("/>") - 1); var o = this.formatString(f); if (-1 != o.indexOf("dayFrequency")) for (var g = parseInt(o[o.indexOf("dayFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent); c;) { if (i++ , new Date(d).getTime() >= t.getTime()) { var u = new Date(d); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(d), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } d.setDate(d.getDate() + g), (new Date(d) > a || s > 0 && i >= s) && (c = !1) } else -1 != o.indexOf("weekday") && (e.RecurrenceData = e.RecurrenceData + "<weekly mo='TRUE' tu='TRUE' we='TRUE' th='TRUE' fr='TRUE' weekFrequency='1' />") } if (-1 != e.RecurrenceData.indexOf("<weekly ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<weekly ")); f = f.substring(8, f.indexOf("/>") - 1); for (var o = this.formatString(f), g = parseInt(o[o.indexOf("weekFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), v = d.getDay(); c;) { for (var h = v; 7 > h; h++)if (-1 != o.indexOf(r[h]) && (s > i || 0 == s) && (i++ , new Date(d).getTime() >= t.getTime())) { var y = new Date(d); y.setDate(y.getDate() + (h - v)); var u = new Date(y); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(y), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } d.setDate(d.getDate() + (7 * g - v)), v = 0, (new Date(d) > a || s > 0 && i >= s) && (c = !1) } } if (-1 != e.RecurrenceData.indexOf("<monthly ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<monthly ")); f = f.substring(9, f.indexOf("/>") - 1); for (var o = this.formatString(f), g = parseInt(o[o.indexOf("monthFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), w = parseInt(o[o.indexOf("day") + 1]); c;) { if (i++ , new Date(d).getTime() >= t.getTime()) { var y = new Date(d); if (y.setDate(w), y.getMonth() == d.getMonth()) { var u = new Date(y); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(y), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } } d.setMonth(d.getMonth() + g), (new Date(d) > a || s > 0 && i >= s) && (c = !1) } } if (-1 != e.RecurrenceData.indexOf("<monthlyByDay ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<monthlyByDay ")); f = f.substring(14, f.indexOf("/>") - 1); for (var o = this.formatString(f), g = parseInt(o[o.indexOf("monthFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), O = o[o.indexOf("weekdayOfMonth") + 1], x = new Date; c;) { if (i++ , new Date(d).getTime() >= t.getTime()) { var y = new Date(d); if (y.setDate(1), -1 != o.indexOf("weekday")) if (0 == y.getDay() ? y.setDate(y.getDate() + 1) : 6 == y.getDay() && y.setDate(y.getDate() + 2), "last" == O) { for (; y.getMonth() == d.getMonth();)x = new Date(y), y.setDate(5 == y.getDay() ? y.getDate() + 3 : y.getDate() + 1); y = new Date(x) } else for (var h = 0; h < D.indexOf(O); h++)y.setDate(5 == y.getDay() ? y.getDate() + 3 : y.getDate() + 1); else if (-1 != o.indexOf("weekend_day")) if (0 != y.getDay() && 6 != y.getDay() && y.setDate(y.getDate() + (6 - y.getDay())), "last" == O) { for (; y.getMonth() == d.getMonth();)x = new Date(y), y.setDate(0 == y.getDay() ? y.getDate() + 6 : y.getDate() + 1); y = new Date(x) } else for (var h = 0; h < D.indexOf(O); h++)y.setDate(0 == y.getDay() ? y.getDate() + 6 : y.getDate() + 1); else if (-1 != o.indexOf("day")) if ("last" == O) { var y = y.setMonth(y.getMonth() + 1); y.setDate(0) } else y.setDate(y.getDate() + D.indexOf(O)); else { for (var h = 0; h < r.length; h++)-1 != o.indexOf(r[h]) && y.setDate(y.getDay() > h ? y.getDate() + (7 - (y.getDay() - h)) : y.getDate() + (h - y.getDay())); if ("last" == O) { for (; y.getMonth() == d.getMonth();)x = new Date(y), y.setDate(y.getDate() + 7); y = new Date(x) } else for (var h = 0; h < D.indexOf(O); h++)y.setDate(y.getDate() + 7) } if (y.getMonth() == d.getMonth()) { var u = new Date(y); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(y), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } } d.setMonth(d.getMonth() + g), (new Date(d) > a || s > 0 && i >= s) && (c = !1) } } if (-1 != e.RecurrenceData.indexOf("<yearly ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<yearly ")); f = f.substring(8, f.indexOf("/>") - 1); for (var o = this.formatString(f), g = parseInt(o[o.indexOf("yearFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), p = parseInt(o[o.indexOf("month") + 1]) - 1, w = parseInt(o[o.indexOf("day") + 1]); c;) { var y = new Date(d); if (y.setMonth(p), y.setDate(w), new Date(d).getTime() <= y.getTime() && (i++ , new Date(d).getTime() >= t.getTime())) { var u = new Date(y); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(y), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } d.setFullYear(d.getFullYear() + g), (new Date(d) > a || s > 0 && i >= s) && (c = !1) } } if (-1 != e.RecurrenceData.indexOf("<yearlyByDay ")) { var f = e.RecurrenceData.substring(e.RecurrenceData.indexOf("<yearlyByDay ")); f = f.substring(13, f.indexOf("/>") - 1); for (var o = this.formatString(f), g = parseInt(o[o.indexOf("yearFrequency") + 1]), c = !0, d = this.parseDate(e.EventDate, e.fAllDayEvent), p = parseInt(o[o.indexOf("month") + 1]) - 1, O = o[o.indexOf("weekdayOfMonth") + 1], w = 0, h = 0; h < r.length; h++)-1 != o.indexOf(r[h]) && "true" == o[o.indexOf(r[h]) + 1].toLowerCase() && (w = h); for (; c;) { var y = new Date(d); if (y.setMonth(p), new Date(d).getTime() <= y.getTime() && (i++ , new Date(d).getTime() >= t.getTime())) { y.setDate(1); var E = y.getDay(); if (y.setDate(E > w ? y.getDate() + (7 - E + w) : y.getDate() + (w - E)), "last" == O) for (var x = new Date(y); x.getMonth() == p;)y = new Date(x), x.setDate(x.getDate() + 7); else y.setDate(y.getDate() + 7 * D.indexOf(O)); if (y.getMonth() == p) { var u = new Date(y); u.setSeconds(u.getSeconds() + e.Duration); var l = this.cloneObj(e); l.EventDate = new Date(y), l.EndDate = u, l.fRecurrence = !1, l.Id = e.Id, l.ID = l.Id, n.push(l) } } d.setFullYear(d.getFullYear() + g), d.setMonth(p), d.setDate(1), (new Date(d) > a || s > 0 && i >= s) && (c = !1) } } return n } return e.EventDate = new Date(this.parseDate(e.EventDate, e.fAllDayEvent)), e.EndDate = new Date(this.parseDate(e.EndDate, e.fAllDayEvent)), [e] }, cloneObj: function (e) { var t; if (null == e || "object" != typeof e) return e; if (e instanceof Date) return t = new Date, t.setTime(e.getTime()), t; if (e instanceof Array) { t = []; for (var a = 0, n = e.length; n > a; a++)t[a] = this.cloneObj(e[a]); return t } if (e instanceof Object) { t = {}; for (var r in e) e.hasOwnProperty(r) && (t[r] = this.cloneObj(e[r])); return t } throw new Error("Unable to copy obj! Its type isn't supported.") } };
var eventResults = data.d.results;
var parsedArray = spEventsParser.parseEvents(eventResults);

var today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate());
var d = today.getDay(),
    diff = today.getDate() - d + (d == 0 ? -6 : 1);
var startOfWeek = new Date(today.setDate(diff));
var endOfWeek = new Date();
endOfWeek = new Date(endOfWeek.setDate(startOfWeek.getDate() + 6));
var _ = shortpoint.base.libs._;
var filteredData = _.filter(parsedArray, function (data) {
    return data.EventDate >= startOfWeek && data.EventDate <= endOfWeek;
});
var sortedData = _.sortBy(filteredData, function (a) {
    return a.EventDate;
});


var $ = shortpoint.$;
currentSite = window.location.protocol + "//" + window.location.host + _spPageContextInfo.webServerRelativeUrl;
TimeZone = {};
 $.ajax({
            url: currentSite + "/_api/Web/RegionalSettings/TimeZone",
            method: "GET",
      async: false,
            headers: { "Accept": "application/json; odata=verbose" },
        }).done(function (response) {
      TimeZone = response.d;
            sortedData.forEach(function(item, index){
        //var d = this.EventDate;
        var localTime = item.EventDate.getTime();
        var localEndTime = item.EndDate.getTime();
        var regionTimeoffset = (TimeZone.Information.Bias + TimeZone.Information.DaylightBias) * 60000;
        var localTimeoffset =  item.EventDate.getTimezoneOffset() * 60000;
        item.EventDate = new Date();
        item.EventDate.setTime(localTime + ((localTimeoffset - regionTimeoffset )));
        item.EndDate = new Date();
        item.EndDate.setTime(localEndTime + ((localTimeoffset - regionTimeoffset )));
        if(item.RecurrenceData != null){
          var instnaceDate = new Date();
          instnaceDate.setTime(localTime );
          item.DisplayId = item.Id + ".0."+ instnaceDate.toISOString().replace(".000Z","Z") ;
        }else{
          item.DisplayId = item.Id;
        }
        });
        return sortedData;
        });   
return sortedData;
        



Click on Connect 


Step 4: Map Columns


In the Items tab, map the columns the way you want:



Display events form in a pop-up (Optional):


Map the url to the display form of the event and then add #Id in the Link field and select lightbox in Linking options


<https://your-site>/Lists/<Events List Title>/DispForm.aspx?ID=#DisplayId


<https://your-site>: Replace with your site URL (for example https://contoso.sharepoint.com)

<Events List Title>: Replace with title of your events list (for example Events)


Example URL: https://contoso.sharepoint.com/Lists/Events/DispForm.aspx?ID=



Click Insert + and you are done!


Now you can see the Events ShortPoint Element with the occurrence(s)!







Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 27 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more