Pergunta

I am having a hard time understanding how a caml query fetches data from a SPO list. Currently, i have set up a client context on an CSOM console application and i am trying to upload a csv file onto a SPOList. The requirements of the project is that i check wether the entry has already passed, in which case i simply delete and insert the new entry, based on a FilenetID hex code. I get the error "The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator." right at the moment that a CamlQuery is initialised, loaded on the client context and executed. Setting up a Logging action showed me that the error above started displayig once the limit 5k list items was reached and at the moment i cannot insert any more new entries. My CamlQuery is the below:

CamlQuery query = new CamlQuery
            {
                ViewXml = String.Format("@<View><Query><Where><Eq><FieldRef Name=\"FilenetID\" />" +
            "<Value Type=\"Text\">{0}</Value></Eq></Where></Query><RowLimit>10</RowLimit></View>", filenetID)
            };
var existingMappings = SpList.GetItems(query);
ClientContext.Load(existingMappings);
ClientContext.ExecuteQuery();
return existingMappings.FirstOrDefault();

The entries based on the FilenetID are unique, meaning that the CamlQuery above must return only one row. I even tried to set the RowLimit attribute but still i get the same error. My next step will be to index the column in question, but i would like to ask a question so that the community could please clarify upon the subject so that i could grasp a better understanding. Have you guys faced any of the above problems?

Foi útil?

Solução

This is by design. Even the expected result only has one row, SP has to enumerate all items and check each of them meets the query condition. This will trigger "list view threshold".

To overcome it, you may have to index the filter column. Check below materials to get more details:

BR

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top