Domanda

Sto utilizzando il modello oggetto client per migrare i dati da una sorgente dati esterna. Il problema è che quando ho impostato ricerca (lista normale o utente) ottengo:

Value does not fall within the expected range.

ho impostato in questo modo:

//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 };

La cosa divertente è che i primi 3 ricerche doesn' eccezione tiro. Ho impostato su 10 campi.

Quindi, tutti i valori di ricerca exsits, prima di 2 o 3 le ricerche degli utenti corrono ok, quando ho rimuovere il commento uno qualsiasi degli altri 3 che getta eccezione. Qualcuno sa cosa potrebbe essere sbagliato? Non client OM ha alcune restrizioni? Chiamo context.ExecuteQuery () una sola volta, dopo essere stata impostata tutti i campi.

modifica:. Anche se io commento prime 2 ricerche non riesce ad eseguire

modifica: Analisi dello stack aggiunto

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...
È stato utile?

Soluzione

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.

Altri suggerimenti

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};
item.Update();
context.ExecuteQuery();

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top