Friday, June 4, 2010

"Value does not fall within the expected range" when adding a calculated column to the library/list.


Symptoms:
You create a document library or a list.
Go to site settings and add a calculated column (named CAL1, or any other name) and then save it. This works fine as this is the first calculated column.
You add another calculated column which calculated the value based on the value from CAL1 (from previous step).
In such a scenario, we get an error "Value does not fall within the expected range". But at the same time, the column gets added to the site and functions as expected.

Error(s):
"Value does not fall within the expected range"

Cause:
By-Design.

If you're trying to use it with a Calculated column, then you're trying to force a value into a column for which SharePoint itself is calculating the value.

i.e. CAL2 value is being calculated from CAL1 value which itself is unknown. Anything that is unknown, .NET will treat it as something out of range. Thus, we are getting the error.

Resolution:
With the above explanation, we do not have a resolution for the issue.
SharePoint should ideally show a warning message stating that we are calculating the value based on a column whose value is unknown. Instead of a friendly error message, we are getting a technical error from .NET/SharePoint which causes confusion that something is failing.

You might find these articles useful