I am trying to get items from the workflow history list, which has more than 5000 entries using the below code
var ctx = SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getByTitle("Workflow history");
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<View><Query><Where><Leq><FieldRef Name='Created' /><Value Type='DateTime'><Today OffsetDays='-100' /></Value></Leq></Where><OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query><RowLimit>10</RowLimit></View>");
var items = list.getItems(camlQuery);
ctx.load(items);
ctx.executeQueryAsync(
function () {
for (var i = 0; i < items.get_count(); i++) {
var pageItem = items.getItemAtIndex(i);
console.log(pageItem.get_fieldValues()['Title']);
}
},
function (msg) {
console.log(msg);
});
This works for lists with items less than 5000. Is there a way to make this work for workflow history list?
P.S: I also tried rest api like this
/_api/web/lists/getbytitle('Workflow History')/items?$filter=(Created ge datetime'2017-10-01T07:00:00.000Z')&$top=5000
I got the below error. I was trying to get items created after Oct 2017
The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.