I get this error.
Error : 500: Internal Server Error: Queries with valid paging cookie should not be executed in this strategy
when I invoke this code in a WebResource in CRM 2011
self.loadWorkItems = function () {
var user = self.user();
var bid = user.BusinessUnitId.Id();
var systemUserId = user.SystemUserId();
var results = new Array();
SDK.REST.retrieveMultipleRecords(
"QueueItem",
"$select=*&$skip=" + self.page() * self.pageSize() + "&$top=" + self.pageSize() + "&$orderby=CreatedOn asc&$filter=OwningBusinessUnit/Id eq guid'" + bid + "' and StateCode/Value eq 0",
function (r) {
results = results.concat(r);
},
function (error) {
self.lastError(error.message);
},
function (x) {
for (var i = 0; i < results.length; i++) {
var item = results[i];
var r = ko.mapping.fromJS(item, workItemMapping);
self.workQueue.push(r);
}
}
);
};
this is part of a knockoutjs viewmodel. I am trying to make a "More" button that goes and gets the next page of data from the server and throws it on the end of the list being displayed.
The page loads just fine and the first page comes back but when the next page is requested I get this error.
Any ideas on how to make the call without the error?
EDIT
I was mistaken It seems that some calls with $skip > 0 work. Going crazy here.
EDIT
I think what this error is trying to tell me is that the skip/top combo is more than the total record count and instead of giving me nothing (as I would expect), it's throwing an exception.
So the new question is how to avoid this stupidity? I guess now I have to count all the records and and make sure I don't page too much.