Below is my CAML query using JS. How can I modify my query in order to avoid the threshold limit error? I have more than 5000 items in the list and I need to retrieve all of them to be exported into excel. Any help is appreciated.

var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Data Entry');

var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><GroupBy Collapse=\'FALSE\'><FieldRef Name=\'Pay_Period\' /></GroupBy><Where><Geq><FieldRef Name=\'ID\'/>' + 
    '<Value Type=\'Number\'>1</Value></Geq></Where></Query></View>');
this.collListItem = oList.getItems(camlQuery);


clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededData), Function.createDelegate(this, this.onQueryFailedData));        
  • How to use this <Gt><FieldRef Name='ID'></FieldRef><Value Type='Number'>0</Value></Gt> <Lt><FieldRef Name='ID'></FieldRef><Value Type='Number'>5000</Value></Lt> in the above query? What will be my next code to add entries from 5000 - 6000? – Keerthi Sep 6 '17 at 20:02
  • Did you try to increase RowLimit in your SPQuery xml? <View><Query>...<RowLimit>99999</RowLimit></Query></View>? – Olga Golubeva Sep 7 '17 at 14:26
  • @OlgaGolubeva Yes. If I add that it gives the threshold limit error. – Keerthi Sep 7 '17 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.