Поделиться через


Sharepoint calendar overlay setting migration issues and solution

Sharepoint 2010 provides nice feature to overlay calendar views.

I have created mulitple calender lists in my sharepoint site and I have used this feature to overlay different calenders views on main calendar list and added this calender list as a list view webpart to a page. Issue I came accross is when I migrate my site one environment to another using site backup and restore operation. After site is restored to different environment, my calender view webpart does not show up any calendar data and throws up below error

  "The Web application at https://spsites.com/sites/ical could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application. (2c52a67a-95df-44d3-8055-2a6b049ba1fb)"

 

Later I realised that every calender view has "CalendarSettings" property which holds the calendar overlay configuration data(in the form of XML) such as weburl, list name , calendar view name and url. Some how the Sharepoint saves WebURL property as is i.e. if you are working dev environment and you specified the "WebURL" of site, this URL is saved as is and it persists.

Below is the calendar settings

<AggregationCalendars>
<AggregationCalendar Id="{99ddb82c-9g2k-4d5c-9b7f-3ee27cf5c972}"
Type="SharePoint"
Name="Calendar"
Description=""
Color="3"
AlwaysShow="True"
CalendarUrl="/Lists/Calendar/calendar.aspx">
<Settings WebUrl="https://spsites.dev.com"
ListId="{C539CE83-EFAF-4AC8-B725-F8D41C9FDB2C}"
ViewId="{A8A9D082-2C61-44D3-BB8A-C855919AB45D}"
ListFormUrl="/Lists/Calendar/DispForm.aspx" />
</AggregationCalendar>
</AggregationCalendars>

 

 

 

 So even when the site is restored to the other environment, "WebURL" value will still point to old environment which cause this above mentioned error.

 

 Solution 

   

   I have programmatically accessed the "CalendarSettings" and replaced the "WebURL" property and also remapped existing calendar view UR

 

   

XmlDocument xml = new XmlDocument()

xml.LoadXml(view.CalendarSettings.Replace("https://spsites.dev.com/sites/ical", ""https://spsites.prod.com/sites/ical"));            

  XmlNodeList calendars = xml.SelectNodes("/AggregationCalendars/AggregationCalendar");             

   if (calendars != null)

      count = calendars.Count;            

   foreach (XmlNode node in calendars)

     {               

     if (node.Attributes["Name"] != null && node.Attributes["Name"].Value == "ROB Calendar") // check for list name

         {

                      XmlElement parentElement = (XmlElement)node;                     

                      string calendarurl = node.Attributes["CalendarUrl"].Value;

                        calendarurl = calendarurl.Substring(calendarurl.LastIndexOf('/') + 1);

                        parentElement.SetAttribute("CalendarUrl", site.ServerRelativeUrl + "/Lists/ROBCalendar/" + calendarurl); //set the calendar url

                       XmlElement childElement = (XmlElement)node.ChildNodes[0];

                        childElement.SetAttribute("ListId", "{" + robList.ID.ToString() + "}"); //list id            

                         SPView robView = checkView(robList.Views, view.Title.ToLower()); //check whether view exists         

                        if (robView != null)

                            childElement.SetAttribute("ViewId", "{" + robView.ID + "}"); // if view exists set the view id otherwise set the default id

                       else

                           childElement.SetAttribute("ViewId", "{" + robList.DefaultView.ID + "}");

                           childElement.SetAttribute("ListFormUrl", site.ServerRelativeUrl + "/Lists/ROBCalendar/DispForm.aspx"); //list form url

                           childElement.SetAttribute("WebUrl", siteURL);//set weburl

                    }

view.CalendarSettings = xml.OuterXml;

            view.Update(); // Update the view

 Finally Calendar shows up data

 

 

</

Comments

  • Anonymous
    September 03, 2013
    I experienced the same issue when I added SSL to my SharePoint sites.  However, I simply exported the data from the main and then deleted the main calendar and created a new one.  I re added the other sub calendars as overlays.  Only took a few moments as I only had a few to resolve.  Great post..  Got me to think of what I needed to do to get this fixed.  Thanks, Kenny