How to use fetch XML query in dynamic CRM JavaScript code

Note: For latest dynamic CRM interview question please click Here.

Let's take an example, I have a fetch xml query which has been downloaded from Advance fine. 

For download the fetch xml go to advance setting click on the advance find symbol for my example I am taking any entity and downloading fetch xml.

Fetch XML: <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">

  <entity name="account">

    <attribute name="name" />

    <attribute name="primarycontactid" />

    <attribute name="telephone1" />

    <attribute name="accountid" />

    <order attribute="name" descending="false" />

    <filter type="and">

      <condition attribute="name" operator="eq" value="Alpine Ski House" />

      <condition attribute="telephone1" operator="eq" value="281-555-0157" />

    </filter>

  </entity>

</fetch>

Now if you want to use fetch xml query in JavaScript code so you must have to follow some instruction otherwise it will give you error like invalid fetch xml query.

Step 1: Open your fetch xml query in notepad and replace all Dubble (") quote into single quote ('). Replace all you will get under edit button in notepad.




Step 2: Convert all the less than symbol (<) to Dubble quote less than ("<).



Step 3: Conver all the greater than symbol (>) to greater than Dubble quote space plus symbol (>"  +).



Step 4: At the end you need to put semicolon (;) and store it into a variable. 



Note: For latest dynamic CRM interview question please click Here.


Comments

Popular posts from this blog

latest dynamics 365 interview questions

difference between enable rule vs display rule in ribbon workbench

If i create one record that created record date is older than 3 days, then I want to perform some operation with the help of business rule.