The attempted operation is prohibited because it exceeds the list view threshold

%3CLINGO-SUB%20id%3D%22lingo-sub-1287513%22%20slang%3D%22en-US%22%3EThe%20attempted%20operation%20is%20prohibited%20because%20it%20exceeds%20the%20list%20view%20threshold%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1287513%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20caml%20query%20as%20below%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%22%3CVIEW%3E%3CQUERY%3E%3CWHERE%3E%3CAND%3E%3CEQ%3E%3CFIELDREF%20name%3D%22'NumericRecordId'%2F%22%3E%3CVALUE%20type%3D%22'Integer'%22%3Exxxxxxx%3C%2FVALUE%3E%3C%2FFIELDREF%3E%3CEQ%3E%3CFIELDREF%20name%3D%22'ContextId'%2F%22%3E%3CVALUE%20type%3D%22'Integer'%22%3Exxxxxx%3C%2FVALUE%3E%3C%2FFIELDREF%3E%3C%2FEQ%3E%3C%2FEQ%3E%3CVIEW%3E%3CORDERBY%3E%3CFIELDREF%20name%3D%22'NumericRecordId'%22%20ascending%3D%22'False'%22%3E%3C%2FFIELDREF%3E%3C%2FORDERBY%3E%3C%2FVIEW%3E%3CVIEWFIELDS%3E%3CFIELDREF%20name%3D%22'Title'%22%3E%3C%2FFIELDREF%3E%3C%2FVIEWFIELDS%3E%3CROWLIMIT%3E100%3C%2FROWLIMIT%3E%3C%2FAND%3E%22%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FWHERE%3E%3C%2FQUERY%3E%3C%2FVIEW%3E%3C%2FP%3E%3CP%3EThis%20works%20fine%20for%20records%20less%20than%205000%20in%20my%20document%20library.%20But%20once%20it%20exceeds%205000%20i%20get%20threshold%20error.%3C%2FP%3E%3CP%3EContextId%20and%20NumericRecordId%20are%20Indexed%20columns.%20I%20tried%20many%20different%20online%20solutions%20but%20not%20able%20to%20get%20through%20this.%20Any%20help%20will%20be%20much%20appreciated.%20Thanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1287513%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1287707%22%20slang%3D%22en-US%22%3ERe%3A%20The%20attempted%20operation%20is%20prohibited%20because%20it%20exceeds%20the%20list%20view%20threshold%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1287707%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F60%22%20target%3D%22_blank%22%3E%40Juan%20Carlos%20Gonz%C3%A1lez%20Mart%C3%ADn%3C%2FA%3E%26nbsp%3B%20Thanks%20for%20your%20suggestion%20.%20can%20you%20just%20provide%20an%26nbsp%3B%20example%20on%20how%20to%20call%20them%20with%20multiple%20parameters%20and%20integrate%20them%3F%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1301831%22%20slang%3D%22en-US%22%3ERe%3A%20The%20attempted%20operation%20is%20prohibited%20because%20it%20exceeds%20the%20list%20view%20threshold%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1301831%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F60%22%20target%3D%22_blank%22%3E%40Juan%20Carlos%20Gonz%C3%A1lez%20Mart%C3%ADn%3C%2FA%3E%26nbsp%3B%20I%20tried%20with%20the%20search%20api's%20as%20well%20and%20again%20ran%20into%20same%20issue%20after%205000%20records%20as%20api%20returns%20500%20(Internal%20Server%20Error)%20while%20applying%20filters.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1302395%22%20slang%3D%22en-US%22%3ERe%3A%20The%20attempted%20operation%20is%20prohibited%20because%20it%20exceeds%20the%20list%20view%20threshold%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1302395%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F612162%22%20target%3D%22_blank%22%3E%40Ankush_Daga%3C%2FA%3E%26nbsp%3BHave%20you%20tried%20using%20PnPJS%20with%20paged%20items%20method.%20Please%20refer%20the%20below%20link%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fpnpjs%2Fsp%2Fitems%2F%23get-paged-items%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fpnp.github.io%2Fpnpjs%2Fsp%2Fitems%2F%23get-paged-items%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20refer%20the%20below%20link%20using%20Search%20API%20using%20PnPJS%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fpnpjs%2Fsp%2Fsearch%2F%23paging-with-searchresultsgetpage%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fpnp.github.io%2Fpnpjs%2Fsp%2Fsearch%2F%23paging-with-searchresultsgetpage%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20it%20helps%2C%20please%20like%20it%20or%20mark%20it%20as%20a%20solution%20if%20it%20resolves%20ur%20clarification%20or%20issue%3CBR%20%2F%3E-Sudharsan%20K...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1302430%22%20slang%3D%22en-US%22%3ERe%3A%20The%20attempted%20operation%20is%20prohibited%20because%20it%20exceeds%20the%20list%20view%20threshold%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1302430%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F144422%22%20target%3D%22_blank%22%3E%40Sudharsan%20K%3C%2FA%3E%26nbsp%3B%20Thank%20for%20your%20response%20but%20this%20seems%20to%20be%20through%20javascript.%20I%20am%20making%20a%20call%20to%20search%20api%20through%20c%23%20desktop%20application.%20So%20it%20would%20not%20be%20a%20feasible%20solution%20for%20me.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1302444%22%20slang%3D%22en-US%22%3ERe%3A%20The%20attempted%20operation%20is%20prohibited%20because%20it%20exceeds%20the%20list%20view%20threshold%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1302444%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F612162%22%20target%3D%22_blank%22%3E%40Ankush_Daga%3C%2FA%3E%26nbsp%3BCan%20you%20refer%20the%20below%20links%20and%20let%20me%20know%20if%20it%20suits%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.codeproject.com%2FArticles%2F281693%2FPaging-SharePoint-List-Items%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.codeproject.com%2FArticles%2F281693%2FPaging-SharePoint-List-Items%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fkeepitsimplekarthik.com%2Fsharepoint%2Flistitemcollectionposition-and-pageinfo%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fkeepitsimplekarthik.com%2Fsharepoint%2Flistitemcollectionposition-and-pageinfo%2F%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1302466%22%20slang%3D%22en-US%22%3ERe%3A%20The%20attempted%20operation%20is%20prohibited%20because%20it%20exceeds%20the%20list%20view%20threshold%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1302466%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F144422%22%20target%3D%22_blank%22%3E%40Sudharsan%20K%3C%2FA%3E%26nbsp%3B%20I%20have%20already%20tried%20using%20'ListItemCollectionPosition'%20.%20It%20works%20fine%20with%20records%20less%20than%205000%20but%20once%20my%20document%20library%20exceeds%20files%20count%20then%20it%20throws%20the%20threshold%20error.%20So%20without%20removing%20'Where'%20clause%20from%20the%20query%20or%20'Filters'%20from%20the%20api's%20it%20throws%20an%20error%20(possibly%20due%20to%20threshold%20limit).%20If%20i%20remove%20this%20where%20clause%20or%20filter%20then%20it%20works%20fine%20with%20row%20limit%20as%20well%20as%20pagination.%20But%20this%20is%20again%20a%20perfromance%20hit%20as%20It%20will%20be%20bringing%20all%20the%20records%20rather%20than%20filtering%20them.%20So%20i%20am%20looking%20for%20some%20approach%20in%20which%20it%20works%20with%26nbsp%3B%20where%20(caml%20query)%20or%20filter%20(Rest%20api's).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1287624%22%20slang%3D%22en-US%22%3ERe%3A%20The%20attempted%20operation%20is%20prohibited%20because%20it%20exceeds%20the%20list%20view%20threshold%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1287624%22%20slang%3D%22en-US%22%3EWell%2C%20what%20I%20would%20recommend%20here%20is%20to%20use%20search%20API%20instead%20of%20doing%20a%20CAML%20Query%3C%2FLINGO-BODY%3E
Occasional Contributor

I am using caml query as below:

 

"<View><Query><Where><And><Eq><FieldRef Name = 'NumericRecordId'/><Value Type = 'Integer'>xxxxxxx</Value></Eq><Eq><FieldRef Name = 'ContextId'/><Value Type = 'Integer'>xxxxxx</Value></Eq></And></Where><View><OrderBy><FieldRef Name='NumericRecordId' Ascending='False' /></View></Query><ViewFields><FieldRef Name='Title' /></ViewFields><RowLimit>100</RowLimit></View>"

This works fine for records less than 5000 in my document library. But once it exceeds 5000 i get threshold error.

ContextId and NumericRecordId are Indexed columns. I tried many different online solutions but not able to get through this. Any help will be much appreciated. Thanks

8 Replies
Well, what I would recommend here is to use search API instead of doing a CAML Query

@Juan Carlos González Martín  Thanks for your suggestion . can you just provide an  example on how to call them with multiple parameters and integrate them?  

@Juan Carlos González Martín  I tried with the search api's as well and again ran into same issue after 5000 records as api returns 500 (Internal Server Error) while applying filters.

 

@Ankush_Daga Have you tried using PnPJS with paged items method. Please refer the below link

https://pnp.github.io/pnpjs/sp/items/#get-paged-items

 

Please refer the below link using Search API using PnPJS

https://pnp.github.io/pnpjs/sp/search/#paging-with-searchresultsgetpage

 

Hope it helps, please like it or mark it as a solution if it resolves ur clarification or issue
-Sudharsan K...

@Sudharsan K  Thank for your response but this seems to be through javascript. I am making a call to search api through c# desktop application. So it would not be a feasible solution for me.

@Sudharsan K  I have already tried using 'ListItemCollectionPosition' . It works fine with records less than 5000 but once my document library exceeds files count then it throws the threshold error. So without removing 'Where' clause from the query or 'Filters' from the api's it throws an error (possibly due to threshold limit). If i remove this where clause or filter then it works fine with row limit as well as pagination. But this is again a perfromance hit as It will be bringing all the records rather than filtering them. So i am looking for some approach in which it works with  where (caml query) or filter (Rest api's).

Hi,
Have you tried using query.QueryThrottleMode = SPQueryThrottleOption.Override;

Refer the below link too

https://www.codeproject.com/articles/1076854/overcoming-the-list-view-threshold-in-sharepoint-c