FetchXML Formatter Tool

It is a Light weight windows application and this tool will be helpful when you are extensively working with FetchXML in Javascript / C# code to get desired result.

Functionality:

It will take FetchXML from Advance Find as an input and convert that into desired format, which can be used into Javascript / C# for further coding.

Pros:

  1. No Need to spend time for FetchXML formatting
  2. It is easy to use.
  3. Works for both Javascript and C# code

Example:

Let us take a simple example of the below FetchXML,

 <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="telephone1" />
    <attribute name="emailaddress1" />
    <attribute name="contactid" />
    <order attribute="fullname" descending="false" />
    <filter type="and">
      <condition attribute="ownerid" operator="eq-userid" />
      <condition attribute="statecode" operator="eq" value="0" />
    </filter>
  </entity>
</fetch>

Provide this as an input to FetchXML formatter Tool, 1. Check Javascript radio button and click on Format to see the below output,

"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"  <entity name='contact'>"+
"    <attribute name='fullname' />"+
"    <attribute name='telephone1' />"+
"    <attribute name='emailaddress1' />"+
"    <attribute name='contactid' />"+
"    <order attribute='fullname' descending='false' />"+
"    <filter type='and'>"+
"      <condition attribute='ownerid' operator='eq-userid' />"+
"      <condition attribute='statecode' operator='eq' value='0' />"+
"    </filter>"+
"  </entity>"+
"</fetch>"

2. Check C# radio button and click on Format to see the below output,

@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
  <entity name='contact'>
    <attribute name='fullname' />
    <attribute name='telephone1' />
    <attribute name='emailaddress1' />
    <attribute name='contactid' />
    <order attribute='fullname' descending='false' />
    <filter type='and'>
      <condition attribute='ownerid' operator='eq-userid' />
      <condition attribute='statecode' operator='eq' value='0' />
    </filter>
  </entity>
</fetch>"

Click Here to download the FetchXML Formatter Tool Exe file

Screen Shots:

FetchXMLFormatter - Pic 1
FetchXMLFormatter - Pic 2
FetchXMLFormatter - Pic 3
FetchXMLFormatter - Pic 4
Please provide your valuable feedback on this article.


Discover more from Arun Potti's Power Platform blog

Subscribe to get the latest posts to your email.

20 thoughts on “FetchXML Formatter Tool

  1. This is really helpful tool, saves our time in formatting fetch xml as required. Most of the times we end up with an error by missing opening or closing quotes.

  2. Hi Arun,

    I want to create fetchxml similar to below SQL query:

    select AccountName from Account where AccountName not in (select AccountName from Application where ProgramElement = “ABC”)

    Any help will much appreciated.

    Thanks,
    Faisal

      • Hi Arun,

        Can you please provide some examples how to create two FetchXMLs to meet this requirement.

        Thanks,
        Faisal

      • It seems the comment field does not allow xml, perhaps this works better…

        <fetch count=”50″>
        <entity name=”account”>
        <attribute name=”name” />
        <filter>
        <condition entityname=”appl” attribute=”accountname” operator=”null” />
        </filter>
        <link-entity name=”application” from=”accountname” to=”accountname” link-type=”outer” alias=”appl”>
        <filter>
        <condition attribute=”programelement” operator=”eq” value=”ABC” />
        </filter>
        </link-entity>
        </entity>
        </fetch>

Leave a Reply