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)

Pagination in Webapi retrive call

(0) ShareShare
ReportReport
Posted on by 161

Hi team,

i have one code to retrive child contacts count as below but i want to implement the paging and want to limit record set to 50 for every call and it should not fetch all 5000 records in a single call.

i am new to webapi so need some assistance on this kinldy suggest how could i embed that concept into this code

function retrieveentityCollection() {

   debugger;

   var entity="contacts";

   var Id = Xrm.Page.data.entity.getId().substring(1, 37);

   var options ="?$select=firstname&$filter=_accountid_value eq " + Id + "&$count=true";

   var serverURL = Xrm.Page.context.getClientUrl();

   var Query = entity + options;

   var req = new XMLHttpRequest();

   req.open("GET", serverURL + "/api/data/v9.0/" + Query, true);

   req.setRequestHeader("Accept", "application/json");

   req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

   req.setRequestHeader("OData-MaxVersion", "4.0");

   req.setRequestHeader("OData-Version", "4.0");

   req.onreadystatechange = function() {

       if (this.readyState == 4 /* complete */ ) {

           req.onreadystatechange = null;

           if (this.status == 200) {

               var data = JSON.parse(this.response);

               if(data['@odata.count']!=null)

                   Xrm.Page.getAttribute("numberofemployees").setValue(data['@odata.count']);

               alert(data['@odata.count']);

               for (var i = 0; i < data.value.length; i++) {

                   var name = data.value[i]["firstname"];

                   Xrm.Utility.alertDialog(name);

               }

           }

           else {

               var error = JSON.parse(this.response).error;

               Xrm.Utility.alertDialog(error.message);

           }

       }

   };

   req.send();

}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Why not use skip and top together:

    var skipRecords = (pageNumber-1) * 10;

    var options ="?$select=firstname&$filter=_accountid_value eq " + Id + "&$skip=" + skipRecords + "&$top=10

    Hope this helps.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Nagaraj,

    Please refer the link below.

    developer.wordpress.org/.../pagination

    Hope this helps.

  • Nagaraj M Profile Picture
    161 on at

    Thanks Gopinath I am not able to reach to the url may be some network or server unavailable issue it seems,

    Can you provide some more links

  • Nagaraj M Profile Picture
    161 on at

    actually i want to fetch more than 5000 records and i am passing fetchxml as query to execute so still is possible to solve this with skip and top together?

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    Refer the links below.

    knpuniversity.com/.../pagination

    developer.wordpress.org/.../pagination

    Hope this helps.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Take a look at the following blog post of using FetchXml with Pagination.

    You can try with top and skip or use the logic in the post.

    www.inogic.com/.../execute-fetchxml-using-web-api-in-dynamics-crm-2016

    Hope this helps.

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

    Here are complete post for pagination in dynamic CRM using javascript

    [View:https://vjcity.blogspot.com/2019/11/paging-fetchxml-queries-in-dynamic-crm.html:750:50]

    [View:https://vjcity.blogspot.com/2019/11/paging-in-dynamic-365-crm-using.html:750:50]

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