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
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]
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.
Hi,
Refer the links below.
knpuniversity.com/.../pagination
developer.wordpress.org/.../pagination
Hope this helps.
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?
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
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,113 Super User 2024 Season 2
Martin Dráb 229,918 Most Valuable Professional
nmaenpaa 101,156