Second Life of a Hungarian SharePoint Geek

September 15, 2012

‘Value does not fall within the expected range’ exception when playing around SharePoint calendars

Filed under: Bugs, Calendar, SP 2010 — Tags: , , — Peter Holpar @ 20:02

Recently I worked with the group calendar feature of SharePoint 2010 (SP1), and observed the following behavior.

We created a new group calendar, and added a new calendar view to the group calendar. A little bit later we decided to switch back our group calendar to a standard one (List Settings / General Settings / Title, description and navigation / Use this calendar to share member’s schedule? : No).

After the modifications, our appended view throws error, when one would like to edit it (ViewEdit.aspx). In this case the following error is displayed:

image

With stack trace:

[ArgumentException: Value does not fall within the expected range.] Microsoft.SharePoint.SPCalendarViewStyleCollection.get_Item(String strTemplate) +21492543 Microsoft.SharePoint.SPCalendarViewStyleCollection.SetDefaultStyleFromExistingView() +341 Microsoft.SharePoint.SPCalendarViewStyleCollection.InitViewStylesXML() +1697 Microsoft.SharePoint.SPCalendarViewStyleCollection.get_Count() +42 ASP._layouts_viewedit_aspx.__Render__control14(HtmlTextWriter __w, Control parameterContainer) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\viewedit.aspx:1140 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +115 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +253 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +87 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +53 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240 Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.RenderChildren(HtmlTextWriter writer) +58 System.Web.UI.Page.Render(HtmlTextWriter writer) +38 Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.Render(HtmlTextWriter writer) +58 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4240

We receive error as well, when would like to display the appended view.

image

[ArgumentException: Value does not fall within the expected range.] Microsoft.SharePoint.SPCalendarViewStyleCollection.get_Item(String strTemplate) +21492543 Microsoft.SharePoint.SPCalendarViewStyleCollection.SetDefaultStyleFromExistingView() +341 Microsoft.SharePoint.SPCalendarViewStyleCollection.InitViewStylesXML() +1697 Microsoft.SharePoint.SPCalendarViewStyleCollection.get_DefaultViewStyle() +16 Microsoft.SharePoint.WebPartPages.ListViewWebPart.CreateChildControls() +721 Microsoft.SharePoint.WebPartPages.WebPartMobileAdapter.CreateChildControls() +72 System.Web.UI.Control.EnsureChildControls() +132 System.Web.UI.Control.PreRenderRecursiveInternal() +61 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394

The default views (including the default Calendar view) have no such issues until we make no modifications before switching back to the standard Calendar list. When we set the default scope of the view – for example, from Week Group to Day Group (then saving), and back to the Week Group again (saving again) – , then we experienced the same issue.

image

The source of the problem seems to be the Default Scope. When we have a group calendar, and set the Default Scope explicitly to a value (like Day Group or Week Group), that is not compatible with the standard calendar, then after altering the list to a standard calendar our view will be erroneous due to the selected scope.

The default calendar seems to have no Default Scope set explicitly, it uses the default scopes (Week Group for the group calendar and Month for the standard one).

You can check it through the SchemaXml property of the View, look for the defined (or missing) CalendarViewStyles node.

You can fix the issue by setting back your calendar to a group calendar, and selecting a Default Scope in your view, that is compatible with the standard calendar (any value without Group in its name). An interesting programmatic approach can be read here.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: