Since Microsoft does not provide an example on how to use fetchXml queries with the Xrm.WebApi calls in JavaScript, we at Thrives feel the moral need to provide you at least one example.
This will be a very basic demonstration, but it will give you an idea on how this works.
Scenario
When opening an existing account record, I want an alert that says hello to all the contacts linked to this account.
I know, I don’t need a fetchXml query to achieve this functionality 😉
Implementation
Explanation
So we need to use the retrieveMultipleRecords method from Xm.WebApi.
The first parameter is the entity name from which you want to retrieve records.
The second parameter is your encoded fetchXml query, preceded by the string ?fetchXml=
In the successCallback you will get the response parameter to work with.
This response object contains an entities attribute, which is an array with the results of your query.
You can loop through this array and process the results in the same way as you are used to when using the retrieveMultipleRecords method without a fetchXml query.
very nice post keep it up https://www.zensly.com/web-development-company-delhi
hI, i TRIED passing FETCHXML to XRM.WebApi.Retrievemultiplerecords AND IT IS GIVING ME AN ERROR "tHE QUERY PARAMETER fETCHxml is not supported"
Hi Vijaya, Maybe the query is not correctly formatted or you have a type in the fetchxml keyword before the actual query? Dit you use the ? before the fetchxml keyword? It has to be ?fetchxml=myFetchXmlQuery in order to work. Can you maybe share you code, that would make it easier to understand why it does not work.
[…] bericht Use FetchXml queries with Xrm.WebApi verscheen eerst op […]
hI, i TRIED passing FETCHXML to XRM.WebApi.Retrievemultiplerecords AND IT IS GIVING ME AN ERROR "tHE QUERY PARAMETER fETCHxml is not supported"