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

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

How i can to retrive all data in html javascript with this exemple of microsoft doc- retrieveMultipleRecords fetchXmlPagingCookie

(0) ShareShare
ReportReport
Posted on by 10

i want to print on my html with grid the data retrieved , if you have some ideas how to parse this on table with pagination. 

Link:  retrieveMultipleRecords (référence de l’API client) dans les applications basées sur un modèle - Power Apps | Microsoft Docs

and code : 

function CreateXml(fetchXml, pagingCookie, page, count) {
var domParser = new DOMParser();
var xmlSerializer = new XMLSerializer();

var fetchXmlDocument = domParser.parseFromString(fetchXml, "text/xml");

if (page) {
fetchXmlDocument
.getElementsByTagName("fetch")[0]
.setAttribute("page", page.toString());
}

if (count) {
fetchXmlDocument
.getElementsByTagName("fetch")[0]
.setAttribute("count", count.toString());
}

if (pagingCookie) {
var cookieDoc = domParser.parseFromString(pagingCookie, "text/xml");
var innerPagingCookie = domParser.parseFromString(
decodeURIComponent(
decodeURIComponent(
cookieDoc
.getElementsByTagName("cookie")[0]
.getAttribute("pagingcookie")
)
),
"text/xml"
);
fetchXmlDocument
.getElementsByTagName("fetch")[0]
.setAttribute(
"paging-cookie",
xmlSerializer.serializeToString(innerPagingCookie)
);
}

return xmlSerializer.serializeToString(fetchXmlDocument);
}

function retrieveAllRecords(entityName, fetchXml, page, count, pagingCookie) {
if (!page) {
page = 0;
}

return retrievePage(entityName, fetchXml, page + 1, count, pagingCookie).then(
function success(pageResults) {
if (pageResults.fetchXmlPagingCookie) {
return retrieveAllRecords(
entityName,
fetchXml,
page + 1,
count,
pageResults.fetchXmlPagingCookie
).then(
function success(results) {
if (results) {
return pageResults.entities.concat(results);
}
},
function error(e) {
throw e;
}
);
} else {
return pageResults.entities;
}
},
function error(e) {
throw e;
}
);
}

function retrievePage(entityName, fetchXml, pageNumber, count, pagingCookie) {
var fetchXml =
"?fetchXml=" + CreateXml(fetchXml, pagingCookie, pageNumber, count);

return Xrm.WebApi.online.retrieveMultipleRecords(entityName, fetchXml).then(
function success(result) {
return result;
},
function error(e) {
throw e;
}
);
}

var count = 3;
var fetchXml =
'<fetch mapping="logical"><entity name="account"><attribute name="accountid"/><attribute name="name"/></entity></fetch>';

retrieveAllRecords("account", fetchXml, null, count, null).then(
function success(result) {
console.log(result);

// perform additional operations on retrieved records
},
function error(error) {
console.log(error.message);
// handle error conditions
}
);

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: How i can to retrive all data in html javascript with this exemple of microsoft doc- retrieveMultipleRecords fetchXmlPagingCookie

    Hi crm dunamics 365,

    Could you tell us where are you stuck? Could not get next page data?

  • crm dunamics 365 Profile Picture
    10 on at
    RE: How i can to retrive all data in html javascript with this exemple of microsoft doc- retrieveMultipleRecords fetchXmlPagingCookie

    hi ,

    I'm trying to create a grid, I manage to retrieve the data, there is a response for to the request, but I can't  manipulate the data in order to display them in a table with pagination, in the console, pagingcookie returned me link and I retrieve all record, but in html I manage to display only the first page but how to do for all record and next pages.

    regards,

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 271

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 91 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 76 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans