SharePoint calendar does not show when in a page as a WebPart

From Cheeky Factor

Status: Resolved
Publication date: 2018-05-14
Last edited by: Garyf
Last updated: 2023 - 09 - 8

The problem

I was asked to add an events calendar to a SharePoint site that is being used as a portal. This would display the calendar as a WebPart on a SharePoint Wiki page.

But, obviously, as with anything SharePointy, this wasn’t as straight forward as just sticking the WebPart in. The issue I encountered was the events were not showing when it was inserted as a WebPart.

The resolution

Please note: cheekyfactor.com or the owners of this site cannot be held responsible if things go wrong. You perform these tasks at your own risk.


Device: HP laptop
Operating system: Windows
Software: SharePoint

Guidance for HP laptop, Windows, SharePoint

After much use of Google and asking specialists in SharePoint I was coming up blank. I did find that it was due to a JavaScript issue. To fix the issue, I had to open the page which the calendar was displayed on in SharePoint designer and add the following code:

<script type=”text/javascript”>
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
SP.UI.ApplicationPages.ElementUtility.$3f = function ($p0) {
return ($p0.substring(0, 3).toUpperCase() == “WPQ”)
? $get(‘WebPart’ + $p0)
$get($p0);
}
}, “SP.UI.ApplicationPages.Calendar.js”);
</script>

This over-rides the default JavaScript in the Wiki page, job done.