Programmatically Setting SharePoint 2010 Calendar Overlays

Posted on Posted in PowerShell Cmdlets, SharePoint 2010

I recently did a project where my client needed several calendars provisioned via a Feature Receiver when a particular type of Site Collection was created; they had one primary calendar and they wanted all the other calendars to be overlaid onto the primary one using SharePoint 2010’s Calendar overlay capabilities.

Here’s a quick summary of this feature if you’re not familiar with it. When you are looking at a calendar you should notice that there is a ribbon button titled “Calendar Overlay”:

image

Clicking this button brings you to the Calendar Overlay Settings page; from this page you can add or edit the overlay calendars. Clicking “New Calendar” brings you to an application page where you can define what calendar to overlay:

image

As you can see from the above screenshot, you can add not just a SharePoint calendar as an overlay but also an Exchange calendar. After configuring calendar overlays you will see overlaid items when looking at the month view for the calendar:

SNAGHTML16503622

In this example, the pink item is coming from the overlay calendar. Overlay items are added dynamically after the page loads (some JavaScript and Ajax take care of loading the items and rendering them on the page).

So that’s the basics from the end-users perspective. Now what about the technical details? Well, there’s not a lot of information out there that describes how this is done but here’s the gist of it – there’s a simple XML structure that is stored in the SPView’s CalendarSettings property; this property defines the overlays. Once you know that the rest is just a matter of figuring out what that structure looks like. The easiest way to start is to simply go through the browser and set up one or two overlays and then use some simple PowerShell to dump out that XML:

SNAGHTML16554e82[4]

Here’s a better view of what that XML looks like:

<AggregationCalendars>
<AggregationCalendar Id="{26ddb82c-9e2b-4c5d-9b7e-4ee25cf5c357}"
Type="SharePoint"
Name="My Overlay Calendar"
Description=""
Color="5"
AlwaysShow="False"
CalendarUrl="/Lists/MyOverlayCalendar/calendar.aspx">
<Settings WebUrl="http://demo"
ListId="{428bd2cb-a32d-4867-b658-6498158636a8}"
ViewId="{09928cd4-9a5e-44ed-9bf2-dfe1fc85661b}"
ListFormUrl="/Lists/MyOverlayCalendar/DispForm.aspx" />
</AggregationCalendar>
</AggregationCalendars>

I want to call particular attention to the WebUrl attribute of the Settings element; this value *must* be the full URL of the SPWeb object that contains the overlay calendar list. Okay, you’re thinking, not a huge deal, SharePoint stores the full URL for lots of things and it doesn’t really pose issues right? WRONG! Think about a scenario where you have an extended web application. So in my example I have an authoring site located at http://demo and I’ve extended this site for anonymous access under the URL http://demo.aptillon.com. Due to what I consider a design flaw with the overlays, the overlay feature will only work when the web application you are accessing the site as matches the web application defined for the WebUrl attribute. So if I were to try and access my overlay using the anonymous site I’d get the following error:

image

And of course, due to this error, the overlays will not show up. So even if I’ve only changed the protocol (http to https) I’d still get this same error. This means that, effectively, calendar overlays using SharePoint lists will only work under the context of the Web Application (and protocol) from which the overlay was defined. (I’ve torn through the code that does this and it’s something that Microsoft should be very embarrassed about – very poor performance and just flat out horribly implemented. Okay, I digress, let’s get back to the details.

Another thing you’ll want to do to understand this XML structure is to look at the code that constructs it. There’s two places to look and both require Reflector or some equivalent disassembler; the first is the SerializeAccessors() method of the Microsoft.SharePoint.ApplicationPages.Calendar.CalendarAccessorManagerImpl class. This method takes the properties provided to it and constructs the XML structure shown above. So where are these properties set? For that we need to look at the BtnOk_Click() method of the Microsoft.SharePoint.ApplicationPages.AggregationCustomizePage class. I’m not going to show the details of these methods here but suffice it to say these methods have everything you need to understand this structure.

As I previously noted, for my particular client I needed to set several overlays within a Feature Activated event; to make this easier (because there was technically several places I had to do this) I created a simple method that I could call; this method took in my target list and the list I wanted to overlay as well as several other properties. For this post I’ve taken that code and created a modified version of it which supports adding Exchange-based calendars. Here’s that code:

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Xml;
using Microsoft.SharePoint;

namespace Lapointe.SharePoint2010.Automation.Common.Lists
{
    public enum CalendarOverlayColor
    {
        LightYellow = 1,
        LightGreen = 2,
        Orange = 3,
        LightTurquise = 4,
        Pink = 5,
        LightBlue = 6,
        IceBlue1 = 7,
        IceBlue2 = 8,
        White = 9
    }

    public class SetListOverlay
    {
        public static void AddCalendarOverlay(SPList targetList, string viewName, string owaUrl, string exchangeUrl, string overlayName, string overlayDescription, CalendarOverlayColor color, bool alwaysShow, bool clearExisting)
        {
            AddCalendarOverlay(targetList, viewName, owaUrl, exchangeUrl, null, overlayName, overlayDescription, color, alwaysShow, clearExisting);
        }
        public static void AddCalendarOverlay(SPList targetList, string viewName, SPList overlayList, string overlayName, string overlayDescription, CalendarOverlayColor color, bool alwaysShow, bool clearExisting)
        {
            AddCalendarOverlay(targetList, viewName, null, null, overlayList, overlayName, overlayDescription, color, alwaysShow, clearExisting);
        }
        private static void AddCalendarOverlay(SPList targetList, string viewName, string owaUrl, string exchangeUrl, SPList overlayList, string overlayName, string overlayDescription, CalendarOverlayColor color, bool alwaysShow, bool clearExisting)
        {
            bool sharePoint = overlayList != null;
            string linkUrl = owaUrl;
            if (sharePoint)
                linkUrl = overlayList.DefaultViewUrl;

            SPView targetView = targetList.DefaultView;
            if (!string.IsNullOrEmpty(viewName))
                targetView = targetList.Views[viewName];

            XmlDocument xml = new XmlDocument();
            XmlElement aggregationElement = null;
            int count = 0;
            if (string.IsNullOrEmpty(targetView.CalendarSettings) || clearExisting)
            {
                xml.AppendChild(xml.CreateElement("AggregationCalendars"));
                aggregationElement = xml.CreateElement("AggregationCalendar");
                xml.DocumentElement.AppendChild(aggregationElement);
            }
            else
            {
                xml.LoadXml(targetView.CalendarSettings);
                XmlNodeList calendars = xml.SelectNodes("/AggregationCalendars/AggregationCalendar");
                if (calendars != null)
                    count = calendars.Count;
                aggregationElement = xml.SelectSingleNode(string.Format("/AggregationCalendars/AggregationCalendar[@CalendarUrl='{0}']", linkUrl)) as XmlElement;
                if (aggregationElement == null)
                {
                    if (count >= 10)
                        throw new SPException(string.Format("10 calendar ovarlays already exist for the calendar {0}.",targetList.RootFolder.ServerRelativeUrl));
                    aggregationElement = xml.CreateElement("AggregationCalendar");
                    xml.DocumentElement.AppendChild(aggregationElement);
                }
            }
            if (!aggregationElement.HasAttribute("Id"))
                aggregationElement.SetAttribute("Id", Guid.NewGuid().ToString("B", CultureInfo.InvariantCulture));

            aggregationElement.SetAttribute("Type", sharePoint ? "SharePoint" : "Exchange");
            aggregationElement.SetAttribute("Name", !string.IsNullOrEmpty(overlayName) ? overlayName : (overlayList == null ? "" : overlayList.Title));
            aggregationElement.SetAttribute("Description", !string.IsNullOrEmpty(overlayDescription) ? overlayDescription : (overlayList == null ? "" : overlayList.Description));
            aggregationElement.SetAttribute("Color", ((int)color).ToString());
            aggregationElement.SetAttribute("AlwaysShow", alwaysShow.ToString());
            aggregationElement.SetAttribute("CalendarUrl", linkUrl);

            XmlElement settingsElement = aggregationElement.SelectSingleNode("./Settings") as XmlElement;
            if (settingsElement == null)
            {
                settingsElement = xml.CreateElement("Settings");
                aggregationElement.AppendChild(settingsElement);
            }
            if (sharePoint)
            {
                settingsElement.SetAttribute("WebUrl", overlayList.ParentWeb.Site.MakeFullUrl(overlayList.ParentWebUrl));
                settingsElement.SetAttribute("ListId", overlayList.ID.ToString("B", CultureInfo.InvariantCulture));
                settingsElement.SetAttribute("ViewId", overlayList.DefaultView.ID.ToString("B", CultureInfo.InvariantCulture));
                settingsElement.SetAttribute("ListFormUrl", overlayList.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl);
            }
            else
            {
                settingsElement.SetAttribute("ServiceUrl", exchangeUrl);
            }
            targetView.CalendarSettings = xml.OuterXml;
            targetView.Update();
            /*
            <AggregationCalendars>
                <AggregationCalendar 
                    Id="{cfc22c0b-688e-4555-b1d0-784081a91464}" 
                    Type="SharePoint" 
                    Name="My Overlay Calendar"
                    Description="" 
                    Color="1" 
                    AlwaysShow="True" 
                    CalendarUrl="/Lists/MyOverlayCalendar/calendar.aspx">
                    <Settings 
                        WebUrl="http://demo" 
                        ListId="{4a15e596-674f-4af7-a548-0b01470e8d75}" 
                        ViewId="{594c2916-14e7-4b08-ba36-1126b825bf45}" 
                        ListFormUrl="/Lists/MyOverlayCalendar/DispForm.aspx" />
                </AggregationCalendar>
                <AggregationCalendar 
                    Id="{cfc22c0b-688e-4555-b1d0-784081a91465}" 
                    Type="Exchange" 
                    Name="My Overlay Calendar"
                    Description="" 
                    Color="1" 
                    AlwaysShow="True" 
                    CalendarUrl="<url>">
                    <Settings ServiceUrl="<url>" />
                </AggregationCalendar>
            </AggregationCalendars>
            */
        }
    }
}

I’m not going to bore you with the details of this code as all I’m doing is basic XML manipulation. I created a couple of method overloads to allow for creating SharePoint or Exchange-based overlays. So, did you notice the namespace? Yup, no point in releasing code here if I’m not going to turn it into a cmdlet Smile

I’m not sure how useful this cmdlet will be in everyday use but imagine the scenario in which you have a primary calendar on your company portal and you want to add it as an overlay on every calendar throughout portal – you could easily do this using this cmdlet. Before we get to that, let’s see the full help for the cmdlet, which I called Set-SPListOverlay:

PS C:\Users\spadmin> help Set-SPListOverlay -full

NAME
    Set-SPListOverlay
    
SYNOPSIS
    Sets calendar overlays for the given list.
    
SYNTAX
    Set-SPListOverlay -Color  -OverlayTitle  [-OverlayDescription ] -OwaUrl  -WebServiceUrl  [-TargetList]  [-ViewName ] [-DoNotAlwaysShow ] [-ClearExisting ] [-AssignmentCollection ] []
    
    Set-SPListOverlay -Color  [-OverlayList]  [-OverlayTitle ] [-OverlayDescription ] [-TargetList]  [-ViewName ] [-DoNotAlwaysShow ] [-ClearExisting ] [-AssignmentCollection ] []
    
    Set-SPListOverlay [-OverlayLists]  [-TargetList]  [-ViewName ] [-DoNotAlwaysShow ] [-ClearExisting ] [-AssignmentCollection ] []
    
    
DESCRIPTION
    Sets calendar overlays for the given list.
    
    Copyright 2010 Falchion Consulting, LLC
    > For more information on this cmdlet and others:
    > http://blog.falchionconsulting.com/
    > Use of this cmdlet is at your own risk.
    > Gary Lapointe assumes no liability.
    

PARAMETERS
    -Color 
        The color to use for the overlay calendar.
        
        Required?                    true
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -TargetList 
        The calendar list to add the overlays to.
        
        Required?                    true
        Position?                    1
        Default value                
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  false
        
    -ViewName []
        The name of the view to add the overlays to. If not specified the default view will be used.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -OverlayList 
        The calendar list to add as an overlay.
        
        Required?                    true
        Position?                    2
        Default value                
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  false
        
    -OverlayLists 
        The calendar lists to add as an overlay.
        
        Required?                    true
        Position?                    2
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -OverlayTitle []
        The title to give the overlay calendar when viewed in the target calendar.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -OverlayDescription []
        The description to give the overlay calendar when viewed in the target calendar.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -OwaUrl 
        Outlook Web Access URL.
        
        Required?                    true
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -WebServiceUrl 
        Exchange Web Service URL.
        
        Required?                    true
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -DoNotAlwaysShow []
        Don't always show the calendar overlay.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -ClearExisting []
        Clear existing overlays. If not specified then all overlays will be appended to the list of existing over        lays (up until 10 - anything after 10 will be ignored)
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -AssignmentCollection []
        Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.
        
        When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  false
        
    
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        "get-help about_commonparameters".
    
INPUTS
    
    
OUTPUTS
    
    
NOTES
    
    
        For more information, type "Get-Help Set-SPListOverlay -detailed". For technical information, type "Get-Help Set-SPListOverlay -full".
    
    ------------------EXAMPLE------------------
    
    PS C:\> Get-SPList "http://server_name/lists/MyCalendar" | Set-SPListOverlay -TargetList "http://server_name/lists/MyOverlayCalendar" -Color "Pink" -ClearExisting
    
    
    This example adds the MyOverlayCalendar calendar as an overlay to the MyCalendar list.
    
    
RELATED LINKS
    Get-SPList 

You can see from the different parameter sets that I’ve made provisions for setting the overlay as a SharePoint list or an Exchange calendar; additionally, I’ve made it so that if you have an array of lists that you wish to add as an overlay you can easily pass that array in as well. So now let’s look at that example:

$mainList = Get-SPList http://demo/lists/myCalendar
foreach ($site in (Get-SPSite http://demo -Limit All)) {
    foreach ($web in $site.AllWebs) {
        foreach ($list in ($web.Lists | ? {$_.BaseTemplate -eq "Events"})) {
            if ($list.ID -eq $mainList.ID) { continue }
            Set-SPListOverlay -TargetList $list `
                -OverlayList $mainList `
                -Color "Pink" `
                -OverlayTitle "Main Portal Calendar" `
                -ClearExisting
        }
        $web.Dispose()
    }
    $site.Dispose()
}

Pretty simple huh? I’m just grabbing the primary list and then I’m looping through all my Site Collections and Sites and then grabbing all the lists that have a base template of “Events”. Once I have the list then I simply call my cmdlet – that’s it – easy right?

Okay, so what if you have a calendar with a bunch of overlays and you need to grab those calendars and do something to them? Well, I threw in a bonus cmdlet called Get-SPListOverlays. This one is really simple – it merely takes in the primary list and then calls a simple helper method that parses the XML structure and grabs each list. I’m not going to bother showing the code as it’s real basic and this post is long enough (just download the source if you’d like to see it) but I will show the cmdlet help:

PS C:\Users\spadmin> help Get-SPListOverlays -Full
NAME
    Get-SPListOverlays
    
SYNOPSIS
    Retrieve all SPList objects set as a calendar overlay on the given list.
    
SYNTAX
    Get-SPListOverlays [-Identity]  [-Web ] [-AssignmentCollection ] []
    
    
DESCRIPTION
    Retrieve all SPList objects set as a calendar overlay on the given list.
    
    Copyright 2010 Falchion Consulting, LLC
    > For more information on this cmdlet and others:
    > http://blog.falchionconsulting.com/
    > Use of this cmdlet is at your own risk.
    > Gary Lapointe assumes no liability.
    

PARAMETERS
    -Identity 
        The calendar whose calendar overlays will be retrieved.
        
        The value must be a valid URL in the form http://server_name/lists/listname or /lists/listname. If a server relative URL is provided then the Web parameter must be provided.
        
        Required?                    true
        Position?                    1
        Default value                
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  false
        
    -Web []
        Specifies the URL or GUID of the Web containing the calendar whose overlays will be retrieved.
        
        The type must be a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh; a valid name of Microsoft SharePoint Foundation 2010 Web site (for example, MySPSite1); or an instance of a valid SPWeb object.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  false
        
    -AssignmentCollection []
        Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.
        
        When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  false
        
    
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        "get-help about_commonparameters".
    
INPUTS
    
    
OUTPUTS
    
    
NOTES
    
    
        For more information, type "Get-Help Get-SPListOverlays -detailed". For technical information, type "Get-Help Get-SPListOverlays -full".
    
    ------------------EXAMPLE------------------
    
    PS C:\> $lists = Get-SPListOverlays "http://server_name/lists/mylist"
    
    
    This example retrieves the calendar overlays for the calendar at http://server_name/lists/mycalendar.
    
    
RELATED LINKS
    Get-SPList 
    Set-SPListOverlay 
    Get-SPWeb 

In the end this turned out to all be pretty simple to do but it was certainly a challenge trying to figure it all out as there’s no documentation (official or otherwise) that I’ve been able to find.

43 thoughts on “Programmatically Setting SharePoint 2010 Calendar Overlays

  1. Hi, I’m going through your article as a basis for assigning overlays to a customised calendar list that i am writing. I am using the List instance template and using a different setuppath to provide a custom master page. No matter what i do the overlays are not appearing. i can see in the code that in my ListViewXML has the xml added, any ideas?? the calenders overlay button is not appearing in the ribbon, is this perhaps a sign that there may be another issue?

    <View Name="{15DF2404-BA30-4C08-9A86-DBAD36A08418}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="CALENDAR" TabularView="FALSE" RecurrenceRowset="TRUE" DisplayName="Calendar" Url="/Lists/CorporateEvents/calendar.aspx" Level="1" BaseViewID="2" ContentTypeID="0x" MobileUrl="_layouts/mobile/viewdaily.aspx" ImageUrl="/_layouts/images/events.png"><Toolbar Type="Standard"/><CalendarSettings><AggregationCalendars><AggregationCalendar Id="{715ce8e8-7c07-45e9-879a-636fc649c41e}" Type="SharePoint" Name="Sales Events" Description="Sales Events" Color="1" AlwaysShow="True" CalendarUrl="/Lists/SalesEvents/calendar.aspx"><Settings WebUrl="http://localhost:41566&quot; ListId="{db93eb5a-15a9-40d4-bd04-c929ac663518}" ViewId="{9b36d43d-c13d-4be5-98b0-b7dbffd95e91}" ListFormUrl="/Lists/SalesEvents/DispForm.aspx"/></AggregationCalendar><AggregationCalendar Id="{c777244f-a924-4cc0-9e7b-9fa3c9ccb45f}" Type="SharePoint" Name="RDMC Events" Description="RDMC Events" Color="7" AlwaysShow="True" CalendarUrl="/Lists/RDMCEvents/calendar.aspx"><Settings WebUrl="http://localhost:41566&quot; ListId="{8f89454a-7e72-4061-b85e-5831b02dffad}" ViewId="{9c4694e7-c076-477d-908a-88529c792190}" ListFormUrl="/Lists/RDMCEvents/DispForm.aspx"/></AggregationCalendar></AggregationCalendars></CalendarSettings><RowLimit>2147483647</RowLimit><ParameterBindings><ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)"/><ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)"/></ParameterBindings><ViewFields><FieldRef Name="EventDate"/><FieldRef Name="EndDate"/><FieldRef Name="fRecurrence"/><FieldRef Name="EventType"/><FieldRef Name="Attachments"/><FieldRef Name="WorkspaceLink"/><FieldRef Name="Title"/><FieldRef Name="Location"/><FieldRef Name="Description"/><FieldRef Name="Workspace"/><FieldRef Name="MasterSeriesItemID"/><FieldRef Name="fAllDayEvent"/></ViewFields><ViewData><FieldRef Name="Title" Type="CalendarMonthTitle"/><FieldRef Name="Title" Type="CalendarWeekTitle"/><FieldRef Name="Location" Type="CalendarWeekLocation"/><FieldRef Name="Title" Type="CalendarDayTitle"/><FieldRef Name="Location" Type="CalendarDayLocation"/></ViewData><Query><Where><DateRangesOverlap><FieldRef Name="EventDate"/><FieldRef Name="EndDate"/><FieldRef Name="RecurrenceID"/><Value Type="DateTime"><Month/></Value></DateRangesOverlap></Where></Query></View>

    1. The overlays, so far as I can tell, will only work with the ootb calendar lists and not a custom list (their implementation for this feels like a total hack so I’d be surprised if it worked with a custom list definition).

  2. Gary,

    Indeed you are right, there is very little info out there on this. I came across your post while looking at the possibility of developing my own custom calendar overlay eg: Not SharePoint list or Exchange but rather an external, publically available calendar that a user may want to consume via their MySite for instance.

    I can’t find anything out there that discusses how extensibile the Calendar Overlay model is (I’ve either not searched for the right thing or it’s just not possible) but did stumble on your article which seems to suggest there may be a AggregationCalendar object tucked away somewhere.

    Guess I’ll need to consult reflector to try and get any further with this!

    ps. When is Automating SharePoint 2010 with PowerShell 2.0 Edition 2 due? It’s a fantastic reference!

    1. Terry, unfortunately the way msft coded this stuff there’s no way to plug another datasource into it. It’s frustrating though because they set things up in such a way that with just a minor bit of additional effort you could plug something in but then they just sort of cheated and short circuited the process thereby hard coded the datasources.

      1. That’s a real shame. The power to take information from anywhere and aggregate it like SharePoint potentially could would be fantastic.

        I’m now wondering if option 2 would be to go back to the BCS to bring in the external calendar as an External Content Type then use this as a calendar overlay. Unfortunatley, this will remove the ability for users to easily setup these calendar overlays without the intervetion of “geeks”…

        Ah well, the best laid plans and all that.

  3. Did you figure out any ways to overlay the calendar view in the web application on an extended site.Any suggestions how to accomplish this ?

    1. There’s no way to do it – the code that does the overlays is hard coded to only work on the current host – so even http vs. https won’t work – it must be the exact same host (it’s some of the crapiest looking code I’ve seen in a long time – truly embarrasing for Microsoft). For my client where we have this issue we are ditching overlays in favor of a third party calendar control.

      1. Thanks for the reply.

        Do you mind telling me the third party calendar control you are using which supports the calendar overlay on extended sites.

        Thanks
        Binod

  4. The only problem with 3rd party is that you can’t then use the “Connect to Outlook” feature. Of course, due to another design flaw with Sharepoint, the overlays won’t pull into outlook either. I’m trying to figure out a way to synchronize calendars into a master so that we can have several overlays and still connect to outlook. This will also fix the web url problem since it’s not using an overlay any longer. Now I just need to figure out how to actually “do” it! Thanks for the post, the info was very helpful.

    1. I ended up using jQuery’s fullcalendar plug-in for the calendar rendering. I then created a custom application page that allowed me to specify a collection of calendars that would belong to a given “setting name”. I put the fullcalendar stuff in a custom web part that allowed the user to select a “setting name” that would be used to determine which calendars to display. The jquery code then does an ajax call to a custom handler that returns the event objects based on the provided setting name. And finally I created another handler that provides the events in iCalendar format sot that I can import or synchronize with outlook, google calendars, iCal, or anything else that supports the format. It’s all in UAT testing right now but will be going live on my client’s site soon.

  5. Hi,

    Congratulation your article was very useful. I’m wondering whether the overlay setup is possible through Client Object Model as well? I’m trying to find something on the web but actually I couldn’t find anything for that. Can somebody help me?

    Thanks!

  6. Complete beginner here (Well almost), really struggling with the basic task of adding an Exchange Online primary calendar to a SP overlay via the SP Online interface.

    I’ve got the OWA set to:

    https://myDomain.onmicrosoft.com/owa/schedule@myDomain.onmicrosoft.com

    And the EWS set to (Currently, I’ve tried allsorts!)

    https://myDomain.onmicrosoft.com/ews/

    On returning to the list view, I see the following errors, depending on which (incorrect) EWS I’ve been trying to use:

    The HTTP request is unauthorized with client authentication scheme ‘Ntlm’. The authentication header received from the server was ‘Basic Realm=””,Negotiate’

    and

    There was no endpoint listening at https://myDomain.onmicrosoft.com/ews that could accept the message. This is often caused by an incorrect address or SOAP action.

    I’m logged in to the SP site as the Mailbox owner, and I’m flat out of ideas. Can anyone offer any assistance?

    1. Not sure what the fix is but it sounds like a kerberos issue. Does the account you’re logged into on the sharepoint site have access to the calendar? (Note that at this time I’ve only messed with adding sharepoint lists to the overlays and not exchange so it could be something simple that I’m just not familiar with).

  7. Gary, how hard would it be to add a parameter to specify which view should be overlayed? We use a checkbox for every calendar item to specify if it should roll up to overlays, and create a filtered view of only roll-up items as opposed to overlaying all items. Thanks!

      1. Hi Gary,

        I am trying to create a calendar overlay in SharePoint 2010 with Exchange option.

        I got the following error.

        could not establish trust relationship for the SSL/TLS secure channel with authority “servername”

        Then I downloaded the security certificate from the site and created the Trust in Central Administration.

        After that I am getting the following error:

        The HTTP request is unauthorized with client authentication scheme ‘Ntlm’. The authentication header received from the server was ‘Basic realm=”

        Is anything to be done in the Exchange server side? Please share your ideas for solving this issue.

        Thanks

  8. Hi Gary,

    Very informative article.
    I had overlays at a site, and then we got the url of the site changed. (Basically this was done the crude way, creating a new site collection and then restoring the old site on the new url.)
    Everything except the overlays work. Because they are creating the old url. I am trying to delete them, and can’t since I get a “file not found” error.
    Any ideas how can I delete this? I can always create new Overlays at this place. but deleting old one’s is important.
    I uncheck the check box for the overlays that throw an exception, but this is a user-wise setting. If I can do this for all the users, even that can help.
    Any ideas, please let me know.

    1. I know powershell is the right way to go about this but if you open the Calendar.aspx page in SharePoint Designer. Look for the Calendar ListView Webpart there is a setting under the tag search for WebUrl=”http://wrognurl” and replace the instances with http://newurl, save the page when done. This fixes the error and will also let you change the overlay settings.

  9. This works wonderfully for automating what I am working with, the only issue I am running into is that although the overlays are loaded and the overlays are set to always show by default using your scripts, they do not activate in the current view unless I go into the overlay and click “OK” Is there a way to commit these overlays so they appear by default in the current view?

  10. Hi,
    I tried this in my SP 2010 site. Even though it gets saved in overlay settings and setting looks perfectly fine to me, overlaid calendar is not displaying and I get the error “The specified calendar datasource was not found in the calendar view. (a37e4f4a-8d5e-43f6-9541-e3320190835e)”
    Would really appreciate if you could help me with this.

  11. Great Stuff.
    Is there any way to read the “Additional Calendar” details. I got the list of all the overlaid calendars. But wanna programatically set/reset the visiblity of the additional calendars.

    Any help would be appretiated.

  12. Hi Gary,
    This is Frank in the Springs, well we finally ‘Upgraded’ to SharePoint 2010. I got the calendar overlay to work for our IT Division’s and each section has their calendars. I created a site for the ‘IT Calendars with the main calendar on the site. My question, “How can I get all the information to show on the main calendar?” When I click on the calendar under the ‘List’ it shows all the colors. I can send you screen shot(s).
    Hope you can help.

  13. Hi Gary – Is there an elegant way/API to fetch events for overlay calendars instead of starting from scratch using the XML?

    Thanks!

  14. In SharePoint Online, I cannot find the CalendarSettings property in the same location as my on-prem site. Is the Overlay xml stored somewhere else? Or, is the CalendarSetting property hidden somehow?

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA

*