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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Error on retrieveMulti...
Power Apps
Unanswered

Error on retrieveMultiple query option as fetchXml

(0) ShareShare
ReportReport
Posted on by 1

Need help

 

Hi All,

 

I am trying to retrieve Multiple records using context.WebApi using query option as fetchXml but it giving an error like fetchXml not supported

 

Info

var _This=this
let fetchXML="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"<entity name='ttt_financeitemmaster'>"+
"<attribute name='ttt_financeitemmasterid' alias='financemasterid'/>"+
"<attribute name='ttt_name' alias='name'/>"+
"<order attribute='ttt_name' descending='false' />"+
"<filter type='and'>"+
"<condition attribute='ttt_type' operator='in'>"+
"<value>918360002</value>"+
"<value>918360000</value>"+
"</condition>"+
"</filter>"+
"</entity>"+
"</fetch>";
context.webAPI.retrieveMultipleRecords('ttt_financeitemmaster','?$fetchXml='+fetchXML)
.then(
function(value: ComponentFramework.WebApi.RetrieveMultipleResponse) {
value.entities.forEach(entity=>{
let option=document.createElement('option')
option.innerHTML=String(entity.name)
option.setAttribute('datVal',String(entity.financemasterid))
_This.ofrItemDD.appendChild(option)
})
_This.myDiv.appendChild(_This.ofrItemDD)
}
,function(reason: any){
console.clear()
console.log('Error prom PCF',reason)
alert(reason)
})

 

error.png
Categories:
  • Mira Ghaly Profile Picture
    11,415 Moderator on at

    @Harshad

    To retrieve data this way I believe you should be using OData 

    Please find the below link on how to use the retrieve multiple Web API with OData queries.

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/retrievemultiplerecords

     

    To be able to generate OData query easily you can use CRMRestBuilder solution.

     

    https://github.com/jlattimer/CRMRESTBuilder

     

    I have also found this article that uses the FetchXML 

    https://powerobjects.com/2018/02/07/using-fetchxml-with-the-new-dynamics-web-api/ but it mentioning encoded fetchxml, so I think you need to encode your fetchxml and also make sure you are using plural name of your entity

     

    https://www.c-sharpcorner.com/article/execute-fetchxml-with-webapi-in-dynamics-365-using-javascript/

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it

  • yocheby Profile Picture
    5 on at

    I had the same error but I fixed it adding first the text "?fetchXml=".

     

    var fetchXml = `?fetchXml=<fetch mapping='logical' >
    <entity name='annotation'>
    <attribute name='subject' />
    <order attribute='subject' descending='false' />
    <link-entity name='opportunity' from='opportunityid' to='objectid' link-type='inner' alias='ad'>
    <filter type='and'>
    <condition attribute='opportunityid' operator='in'>
    <value uiname='Oppty - Con One' uitype='opportunity'>${regardingObjectId}</value>
    </condition>
    </filter>
    </link-entity>
    </entity>
    </fetch>`;

     

    // Execute the retrieve:

     Xrm.WebApi.retrieveMultipleRecords("annotation", fetchXml).then(

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard