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

Notifications

Announcements

Community site session details

Community site session details

Session Id :

How to Retrieve Records using FETCHXML using JavaScript in MSCRM or Dataverse

Ram Prakash Duraisamy Profile Picture Ram Prakash Duraisamy 5,593 Super User 2025 Season 2
In this blog we will see how to How to Retrieve Records using FETCHXML using JavaScript in MSCRM or Dataverse

1. Prepare FetchXML ( Login to CRM or Dataverse then Go to Advance Find and Frame your Query and Download the FetchXML)
2. Consider am retrieving All Accounts

function retriveRecordusingFetchXML() {
    var fetchXml = `
<fetch>
  <entity name="account">
    <attribute name="accountid" />
    <attribute name="name" />
  </entity>
</fetch>`;

    var encodedFetchXML = encodeURIComponent(fetchXml);
    var fetchXmlRequest = "?fetchXml=" + encodedFetchXML;
    Xrm.WebApi.retrieveMultipleRecords("account", fetchXmlRequest).then(
        function success(result) {
            for (const record of result.entities) {
                var name = record.name;
            }
        },
        function (error) {
            var alertMessage = { text: error.message };
            Xrm.Navigation.openAlertDialog(alertMessage, null);
        }
    );
}

Use the Above Code to retrieve Record 

you can change the FetchXML based on your requirement.

Comments