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