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);
          }
       );
  • necsa Profile Picture
    necsa 3,455 on at
    RE: how we can retrieve multiple records from a form using JavaScript for Custom Dashboard

    Which data with which data do you want to compare?

  • unbeatable Profile Picture
    unbeatable 365 on at
    RE: how we can retrieve multiple records from a form using JavaScript for Custom Dashboard

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

  • necsa Profile Picture
    necsa 3,455 on at
    RE: how we can retrieve multiple records from a form using JavaScript for Custom Dashboard

    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
    unbeatable 365 on at
    RE: how we can retrieve multiple record from a form using JavaScript

    pastedimage1614337721920v1.png

    pastedimage1614337887317v2.png

  • unbeatable Profile Picture
    unbeatable 365 on at
    RE: how we can retrieve multiple record from a form using JavaScript

    Thanks for the reply

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

  • Suggested answer
    necsa Profile Picture
    necsa 3,455 on at
    RE: how we can retrieve multiple record from a form using JavaScript

    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);
              }
           );

  • Clofly Profile Picture
    Clofly 260 on at
    RE: how we can retrieve multiple record from a form using JavaScript

    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.

  • unbeatable Profile Picture
    unbeatable 365 on at
    RE: how we can retrieve multiple record from a form using JavaScript

    Not Working

  • Clofly Profile Picture
    Clofly 260 on at
    RE: how we can retrieve multiple record from a form using JavaScript

    Hi Partner,

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

    Regards,

    Clofly

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,307 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans