Hello All,
I am follow the simpleSPA application with adal.js ,now i am able retrieve the record ,using following code given below,
My Problem ,I don't know still records are exists in entity ,to retrieve using paging ... I want all these values in grid with pages ...when ever clicks on page 2 or 3 or 4 ... i want retrieve those page records,is it possible ? if not what is the way first ,next ,previous, last at-least these 4 options are possible .
function retrieveNextPage() {
authContext.acquireToken(organizationURI, retrieveNextPage1);
}
function retrieveNextPage1(error, token)
{
var fetchxml = "<fetch mapping='logical' page='2' count='10' pagingcookie='%253ccookie%2520page%253d%25221%2522%253e%253caccountid%2520last%253d%2522%257bB8A19CDD-88DF-E311-B8E5-6C3BE5A8B200%257d%2522%2520first%253d%2522%257b475B158C-541C-E511-80D3-3863BB347BA8%257d%2522%2520%252f%253e%253c%252fcookie%253e'>" +
" <entity name='account' >" +
" <attribute name='emailaddress1' />" +
" <attribute name='address1_city' />" +
" <attribute name='accountid' />" +
" <attribute name='parentaccountid' />" +
" <attribute name='address1_composite' />" +
" <attribute name='name' />" +
" </entity>" +
"</fetch>";
var req = new XMLHttpRequest()
req.open("GET", encodeURI(organizationURI + "/api/data/v9.0/accounts?fetchXml=" + fetchxml), true);
//Set Bearer token
req.setRequestHeader("Authorization", "Bearer " + token);
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.setRequestHeader("Prefer", "odata.include-annotations=*");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null;
if (this.status == 200) {
var accounts = JSON.parse(this.response).value;
var temp = JSON.parse(this.response);
temp["@Microsoft.Dynamics.CRM.fetchxmlpagingcookie"];
var entityObj = [];
var pagingInfo = null;
debugger;
//Check if results contains cookies
//if yes then retrieve next set of records
if (temp["@Microsoft.Dynamics.CRM.fetchxmlpagingcookie"] != null) {
document.getElementById("next").style.display = "block";
document.getElementById("nxtPage").textContent = "";
document.getElementById("nxtPage").textContent = temp["@Microsoft.Dynamics.CRM.fetchxmlpagingcookie"];
}
renderAccounts(accounts);
}
else {
var error = JSON.parse(this.response).error;
console.log(error.message);
errorMessage.textContent = error.message;
}
}
};
req.send();
}

Thanks ,
In Advance.
https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/walkthrough-registering-configuring-simplespa-application-adal-js