CRM 4 – How to get the Fetch xml from an advanced find

I was wondering what the fetch xml was from an advanced find today and to get this is suprisingly easy.

All you have to do is run an advanced find.

Press F12

go to the Script tab

type in


and you shall be rewarded with the FetchXml used to return the results in the advanced find


"<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="customeraddress"><attribute name="name"/><attribute name="postalcode"/><attribute name="telephone1"/><attribute name="customeraddressid"/><order attribute="name" descending="false"/><link-entity name="account" from="accountid" to="parentid" alias="aa"><filter type="and"><condition attribute="accountid" operator="eq" uiname="Hosk Account" uitype="account" value="{F3D4F7ED-74EE-E011-A607-00155D6A3702}"/></filter></link-entity></entity></fetch>"

9 thoughts on “CRM 4 – How to get the Fetch xml from an advanced find

  1. Jamie Miley (@mileyja) October 5, 2011 / 8:17 pm

    I was getting ready to poke some fun at you until I read it again and realized you were talking about CRM 4 and not 2011. 🙂

    Nice post!


  2. Hosk October 5, 2011 / 8:26 pm

    yep, I am currently working on a CRM 4 project and everything seems difficult.

    using the DynamicEntity with it’s properties

    no solution files

    having to use special CRM variables!!

    everything is slightly different.

    CRM 2011 is a fantastic improvement, I look forwarding to going back there after this project


  3. Nick November 10, 2011 / 2:02 pm

    If you thought CRM 4.0 was tricky, try working with CRM 1.0, CRM 1.2 and CRM 3.0!

    Thankfully all my clients are on at least CRM 4.0…

    Another great tool for generating FetchXML code is “Stunnware Tools for Microsoft Dynamics CRM 4.0”. It gives you a bit more flexibility when it comes to creating certain links/joins that can’t be easily done in CRM 4.0 Advanced Find.

    The community edition is free and has a bunch of other goodies like a sitemap and isv config editor as well as a trace file viewer. (And a bunch more…)

    I know that there are a few other FetchXML tools out there as well.


  4. H December 10, 2012 / 4:23 pm

    It seems that this approach doesn’t work in Windows 8 / IE10 because the resultRender.FetchXml object isn’t there.
    Fortunately there is another simple way: instead of searching for resultRender.FetchXml, type advFind.FetchXml in the Javascript console and it will display the fetchXml.


  5. Adamushino May 10, 2013 / 1:47 am

    Can anyone tell me where the code would start and end if I wanted to use the fetchxml to create a report in BIDS (Visual Stuido) that linked to the CRM server…. (disclaimer: I’m not very good at IT)


      • adamushi May 10, 2013 / 2:55 pm

        very original. I should have emphasized I’m using CRM 4.0 Online. I already know how to get fetchxml for 2011.

        thanks for being a dick though


      • Hosk May 10, 2013 / 3:00 pm

        I’m being a dick!

        you put half a question on a blog post which it isn’t related to.

        I then look up the answer to your poorly worded question, wrap it up inside a small bit of humour and I am the dick!

        why exactly should I spend my time answering questions for you anyway?


  6. Naveed Butt October 12, 2015 / 6:58 am

    I am getting half of the Xml in CRM 4 using resultRender.FetchXml.value. How can I increase the console buffer size to get whole of the Xml using the console command.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s