web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Xrm.Web.retrieveMultipleRecords doesn't return nextLink

(0) ShareShare
ReportReport
Posted on by 46

Hi Experts,

I am trying to retrieve records using Xrm.Web.retrieveMultipleRecords request with the help of fetchxml but the result doesn't return nextLink.

var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' count='1'>" +

"<entity name='contact'>" +
"<attribute name='fullname' />" +
"<attribute name='telephone1' />" +
"<attribute name='contactid' />" +
"<order attribute='fullname' descending='false' />" +
"<filter type='and'>" +
"<condition attribute='lastname' operator='like' value='u%' />" +
"</filter>" +
"</entity>" +
"</fetch>";

var retrieveRecord1 = Xrm.Web.retrieveMultipleRecords("contact", "?fetchXml=" + encodeURIComponent(fetchXml), 1);

I have 3 contact records which satisfies above fetchxml but still I don't get nextLink using fetchxml. 

*This post is locked for comments

I have the same question (0)
  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    I may be wrong but it looks like the Next Link is not supported when you use FetchXml. Unfortunatly it is not mentioned in amy documentation yet so you may want to check this with Microsoft Support directly.

    Hope this help.

  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    You could refer to this blog.

    balugajjala.wordpress.com/.../

    I saw that you set it to return only one record per page, so as you said there are 3 records exist, there should be the "nextLink" attribute. 

    So you could also debug your code and see what's the content of "result".

    BTW, why did you add "count = 1" in your fetchxml? This code means you will only get 1 record in your result. Remove it and try again.

    Hope it helps.

    Best Regards,

    Leo

  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    you need to remove count='1' from your fetchxml, otherwise the query will always return 1 record.

    you are already doing the paging with the third argument (maxPageSize) of your retrieveMultipleRecords

  • Vikasdugi Profile Picture
    12 on at

    Hi Guido,

    We are facing the same issue with Xrm.Page.retrieveMultipleRecords using fetchxml where we get the nextLink value as undefined.
    We have more than 5000 account records in CRM but it give first page set of records and the nextLink value as undefined.
    We also try with adding maxPageSize parameter but still facing same issue. This issue come with fetchxml only not with the Odata query.

    please find screenshot below:

    4276.Untitled4.png

  • bsd Profile Picture
    5 on at

    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;
                }
            }
    
    
    
    

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans