3
votes

I am getting below error while querying SharePoint list,list has 5005 records and threshold limit is 5000. I have a sharepoint list having different folders and i am using CAML query with RecursiveAll to get records from all folders. I am getting this error :-

The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator. at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at

My query is

"<View Scope='RecursiveAll'> <RowLimit>1000</RowLimit><Query><Where><Eq><FieldRef Name='Year' /><Value Type='Text'>" + Period + "</Value></Eq></Where></Query></View>";

Year is indexed column.If i remove where clause,it starts working.It seems to me recursiveall is not working with where clause.

I don't want to change list threshold limit.

2
do you want a pure javascript solution ? i have a CSOM c# solution, should i post it ?Gautam Sheth
can you share the code that you are using ?Gautam Sheth

2 Answers

1
votes

The default threshold for a list is 5000. You need to change the SharePoint Configuration settings for this list to have a higher threshold. Not sure what version of SharePoint you are on, but if you can access Central Admin here is an article explaining how to change it.

If you are using SharePoint Online, I think you might be stuck, but one of these answers has a supposed work around for it.

1
votes

To overcome this issue, you will need to use the ContentIterator. Essentially you are breaking up the query in batches of e.g. 2000 items. From the Microsoft website:

SharePoint Server provides a new API, ContentIterator, to help with accessing more than 5,000 items in a large list without hitting a list throttling limit and receiving an SPQueryThrottleException. ContentIterator implements a callback pattern for segmenting the query for processing a single item at a time. Consider using this capability if you need to process a large number of items that may exceed a throttling limit. The following trivial example demonstrates the approach used with ContentIterator tested with a list returning 20,001 items from the query.

For official documentation, see here.

This example may also help.