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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

how we can retrieve multiple records from a form using JavaScript for Custom Dashboard

(0) ShareShare
ReportReport
Posted on by 365
Hi, I am trying to use this code to fetch records and applying to a dashboard to filter according to the record but I am getting an error in this code.
 
debugger;    
    var formContext = context.getFormContext();
    var FetchXML="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
    "<entity name='campaign'>" +
    "<attribute name='name' />" +
    "<attribute name='istemplate' />" +
    "<attribute name='statuscode' />" +
    "<attribute name='createdon' />" +
    "<attribute name='campaignid' />" +
    "<attribute name='typecode' />" +
    "<order attribute='name' descending='true' />" +
  "</entity>" +
  "</fetch>";
  FetchXML = "?fetchXml=" + encodeURIComponent(FetchXML);

  parent.Xrm.WebApi.retrieveMultipleRecords("campaign",FetchXML).then(
            function success(result){
                debugger;
          for(var i=0;i<result.entities.length;i++){
              console.log(result.entities[i]);
              }
          },
          function(error){
              debugger;
              console.log(error.message);
          }
       );
I have the same question (0)
  • Clofly Profile Picture
    260 on at

    Hi Partner,

    It seems that "result.entities.lenght" in your code should be "result.entities.length".

    Regards,

    Clofly

  • unbeatable Profile Picture
    365 on at

    Not Working

  • Clofly Profile Picture
    260 on at

    Open console and check error message in Network > XHR.(The error request is marked with red color, error message can be found in the request response data.)

    If you encounter any problem during the process, please share some screenshots, which may help to better understand your question.

  • Suggested answer
    necsa Profile Picture
    3,455 on at

    Please try following code:

       
        var fetchXML="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
        "<entity name='campaign'>" +
        "<attribute name='name' />" +
        "<attribute name='istemplate' />" +
        "<attribute name='statuscode' />" +
        "<attribute name='createdon' />" +
        "<attribute name='campaignid' />" +
        "<attribute name='typecode' />" +
        "<order attribute='name' descending='true' />" +
      "</entity>" +
      "</fetch>";
      fetchXML = "?fetchXml=" + encodeURIComponent(fetchXML);

      Xrm.WebApi.retrieveMultipleRecords("campaign",fetchXML).then(
                function success(result){
                   
              for(var i=0;i<result.entities.length;i++){
                  console.log(result.entities[i]);
                  }
              },
              function(error){
                 
                  console.log(error.message);
              }
           );

  • unbeatable Profile Picture
    365 on at

    Thanks for the reply

    I have to apply this code into a custom dashboard and it's not working there

  • unbeatable Profile Picture
    365 on at

    pastedimage1614337721920v1.png

    pastedimage1614337887317v2.png

  • necsa Profile Picture
    3,455 on at

    I understand. You use parent. Xrm...  which is deprecated. Please use as a reference the following link and match your code:

    docs.microsoft.com/.../important-changes-coming

    itsfascinating.com/.../

  • unbeatable Profile Picture
    365 on at

    Now I am getting data, can you please tell me how to compare data so that I can filter

  • necsa Profile Picture
    3,455 on at

    Which data with which data do you want to compare?

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans