Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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...
share|improve this question
That exception (ArgumentOutOfRange) makes me think that your column names are probably wrong, so double check these. –  James Love Jun 15 '11 at 7:58
+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 '11 at 8:06
Good method there, Steve. –  James Love Jun 15 '11 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 –  Andrej Cimperšek Jun 15 '11 at 8:17
Got a stack trace? (I swear I'm not this guy: 28.media.tumblr.com/tumblr_l8sp0mqEfG1qav3jwo1_400.jpg) :) –  James Love Jun 15 '11 at 8:20

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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