Fix “Value does not fall within the expected range” Error in SharePoint
Problem: SharePoint site gave “System.ArgumentException: Value does not fall within the expected range” error!
Here are some possible root causes and solutions:
Case 1: While fetching List item Lookup values programmatically
Root cause: List view threshold value exceeded! This occurs due to the throttling limit on the list view lookup threshold value under web application settings. Try increasing it.
- Go to Central Administration >> Application Management >> Manage web applications
- Select your web application, click on General Settings >> Resource Throttling from the ribbon
- Enter the value for List View Lookup Threshold. E.g. 36
PowerShell script to increase list view lookup threshold value.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$WebApp = Get-SPWebApplication "https://sharepoint.crescent.com/"
#Set List View Lookup Threshold
$WebApp.MaxQueryLookupFields = 36
$WebApp.Update()
Case 2: Invalid Field Names
When fetching fields, use internal field names or check whether the particular field exists before getting its value. E.g., use item.Fields.ContainsField(“Title”) before fetching or updating a specific field. So, if you got this error after activating a feature or deploying a solution, the culprit is your recent feature/solution!
Case 3: During Check-In under SharePoint Document Library
Got this error while checking in a document? Well, the solution is simple – Do not set the required field property to true on your content types!
Hi I’m Getting this error while clicking version history of Documents. Any idea about this?