RE: Xrm.Web.retrieveMultipleRecords doesn't return nextLink
Sorry, posted this on the wrong thread....
I know this is an old thread, but I recently dug into the issue.
In global.ashx there is a function that incorrectly attempts to read the next link off the response (@odata.nextLink instead of @Microsoft.Dynamics.CRM.fetchxmlpagingcookie):
XrmClientApi.WebApi.WebApiService.$l = function($p0, $p1, $p2, $p3, $p4, $p5) {
var $v_0 = {};
var $v_1 = $p2.responseText;
switch ($p3) {
case 0:
if ($v_1.length > 0) {
$v_0 = JSON.parse($v_1);
}
$p5.resolve($v_0);
break;
case 2:
case 3:
case 4:
var $v_2 = new XrmClientApi.WebApi.EntityReference(XrmClientApi.WebApi.WebApiParser.getGuidFromResponse($p2), $p4);
$p5.resolve($v_2);
break;
case 1:
var $v_3 = null;
if ($v_1.length > 0) {
var $v_6 = JSON.parse($v_1);
if ($v_6) {
$v_3 = new XrmClientApi.WebApi.RetrieveMultipleResponse($v_6['value'], $v_6['@odata.nextLink']);
}
}
$p5.resolve($v_3);
break;
case 5:
$p5.resolve(XrmClientApi.WebApi.WebApiService.$w($p2));
break;
case 6:
var $v_4 = $p5;
var $v_5 = XrmClientApi.WebApi.WebApiParser.parseBatchResponse($p2, $v_4);
$p5.resolve($v_5);
break;
}
}
It's totally unsupported, but correcting this function makes the paging cookie return properly. Run this before running the retrieve multiple and see that the next link does return and is usable:
XrmClientApi.WebApi.WebApiService.$l = function ($p0, $p1, $p2, $p3, $p4, $p5) {
var $v_0 = {};
var $v_1 = $p2.responseText;
switch ($p3) {
case 0:
if ($v_1.length > 0) {
$v_0 = JSON.parse($v_1);
}
$p5.resolve($v_0);
break;
case 2:
case 3:
case 4:
var $v_2 = new XrmClientApi.WebApi.EntityReference(XrmClientApi.WebApi.WebApiParser.getGuidFromResponse($p2), $p4);
$p5.resolve($v_2);
break;
case 1:
var $v_3 = null;
if ($v_1.length > 0) {
var $v_6 = JSON.parse($v_1);
if ($v_6) {
$v_3 = new XrmClientApi.WebApi.RetrieveMultipleResponse($v_6['value'], $v_6['@Microsoft.Dynamics.CRM.fetchxmlpagingcookie']);
}
}
$p5.resolve($v_3);
break;
case 5:
$p5.resolve(XrmClientApi.WebApi.WebApiService.$w($p2));
break;
case 6:
var $v_4 = $p5;
var $v_5 = XrmClientApi.WebApi.WebApiParser.parseBatchResponse($p2, $v_4);
$p5.resolve($v_5);
break;
}
}