I'm using client object model to migrate data from some external data source. The problem is that when I set lookup (normal list or user) I get:

Value does not fall within the expected range.

I set it like this:

//usr is an instance of User, and it exsists
item["Author"] = new FieldUserValue() { LookupId = usr.Id };

//this also fails, source is int, an ID of item in the lookup list that exists
item["DocumentSource"] = new FieldLookupValue() { LookupId = source };

The funny thing is that first 3 lookups doesn' throw exception. I set about 10 fields.

So, all lookup values exsits, first 2 or 3 user lookups run ok, when I uncomment any of the other 3 it throws exception. Anybody know what could be wrong? Does Client OM have some restrictions? I call context.ExecuteQuery() only once, after I set all fields.

edit: even if I comment out first 2 lookups it fails to execute.

edit: stack trace added

at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at MyClass.Run() in Path\To\My\File.cs:line 364
//MyClass is the class name and path is the path to my file...
  • That exception (ArgumentOutOfRange) makes me think that your column names are probably wrong, so double check these.
    – James Love
    Jun 15, 2011 at 7:58
  • 2
    +1 for the James love bet. I use to do : var field=item.Fields.GetFieldByInternalName("DocumentSource"); item[field.ID] = thevalue;. It avoid naming conflicts between the internal name and display name, and also avoid localization issues
    – Steve B
    Jun 15, 2011 at 8:06
  • 1
    Good method there, Steve.
    – James Love
    Jun 15, 2011 at 8:09
  • James Love: nope it's not that, I copied internal name of the field... It must be some other strange thing... Steve B: nice method, but field's name is not the problem
    – redman
    Jun 15, 2011 at 8:17
  • 4
    Got a stack trace? (I swear I'm not this guy: 28.media.tumblr.com/tumblr_l8sp0mqEfG1qav3jwo1_400.jpg) :)
    – James Love
    Jun 15, 2011 at 8:20

2 Answers 2


I've found that updating Lookup fields via the Client Object Model appears to be limited by the View Lookup Threshold setting in the Resource Throttling settings for your web app (central administration). If your limit is 8, updating 8 fields will work, but 9 will fail with the Value does not fall within the expected range. error. This is likely due to the ListItem "reloading" the fields once the update has been done (refreshing itself) and hitting the limit. Updating only a subset of the fields (say, 5 out of 9) works perfectly.

I'm going to open a ticket with MS support and see what they can tell us about this issue. There are significant considerations to bypassing this behavior by performing multiple updates, especially in scenarios with versions enabled.

  • I have received this error before but for a different reason. This is such bad API design! If the API uses such an error message to indicate what you explained, then it might as well just indicate anything! "Value does not fall within the expected range." does not mean View Lookup Threshold has been exceeded. The error message could be just "Sorry something bad happened!" I blogged about this pain here: mazdev.blogspot.ae/2015/06/…
    – Lzh
    Jul 22, 2015 at 19:33
  • It's basically just the error that SharePoint is throwing up. The API itself doesn't have any mechanism to distinguish the cause of the error, only that it received an ArgumentException when calling the SP API. While one could argue that the API should perform checks and return GOOD errors before calling SharePoint, the work involved would be... considerable. At least you can always check the ULS on the server to figure out where the exception was thrown.
    – CMerat
    Jul 27, 2015 at 14:13
  • Yes, SP API should return useful error messages. It's not a considerable amount of effort if you plan for it from the start. Instead of throw new Exception(); you'd throw new ParticularException("with useful information", innerexception, otherdata, etc);
    – Lzh
    Jul 28, 2015 at 7:49
  • I receive the error when creating a new list item. I only set ONE field and that fails. When I try in a list with only a couple of columns, it works, so it must be the threshold. As it is O365 I cannot change it :(
    – Boland
    Sep 14, 2015 at 1:17

I'm unable to reproduce your issue. I've tried using a list with 6 lookups and set them all plus Author:

var context = new ClientContext("http://aasp2010ifa:41000/sites/docid2");
var web = context.Web;
var list = web.Lists.GetByTitle("TestLookup");
var item = list.AddItem(new ListItemCreationInformation());
item["Look"] = new FieldLookupValue {LookupId = 1};
item["Look2"] = new FieldLookupValue {LookupId = 2};
item["Look3"] = new FieldLookupValue {LookupId = 3};
item["Look4"] = new FieldLookupValue {LookupId = 2};
item["Look5"] = new FieldLookupValue {LookupId = 3};
item["Author"] = new FieldLookupValue {LookupId = 9};

Try stripping back your code to something that works, or please provide a more complete code sample that we can reproduce.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.