locked
CRM 2011: in Javascript, query using JSON or FetchXML? RRS feed

  • Question

  • Working on some custom Javascript for the Case/Incident entity in CRM 2011. I have need to do quick querying within the JS to get single records based on a GUID, and then set other fields based on the results of the query.  (Ex: Query the responsible contact and get the phone number and email address to display for reference).

    I have seen example of how to do these types of queries using FetchXML, and others that use the JSON query directly to the /XRMServices/2011/OrganizationData.svc/entity URL.

    Anyone done any independent performance testing to see if one is faster than the other, or are they basically the same? 

    I am mostly using FetchXML in the majority of my queries in the Form Load event, and it seems kind of slow.  There could be other reasons why, but I want to eliminate the queries. before I move on.  I am thinking about converting most of the appropriate queries to JSON, but I don't want to waste the time if it's not a significant performance increase.

    Thanks!


    • Edited by ChrisH5491 Sunday, December 4, 2011 8:47 PM
    Sunday, December 4, 2011 8:47 PM

All replies

  • No opinions on this from anyone?  What are people using JSON or FetchXML?
    Monday, December 5, 2011 7:34 PM
  • I nearly replied on this earlier Chris - I don't have any data on performance of the code though. What I would say is that as a developer I much prefer the syntax of the JSON query, I can get a lot more code written with JSON in the same amount of time & I don't have to concatenate all those strings together to create the XML post anymore - Jeez it's worth it for that alone! :)

    My gut feeling is that JSON should give a performance benefit too - it seems more rationalised, but I don't have any proof of that.... it's just a feeling really. Maybe someone more familiar with the inner workings of JSON & OData will have some input.

    Hope that helps, or at least gets the discussion going. 


    Paul Dowman, CRM Developer
    Monday, December 5, 2011 10:36 PM
  • I did some rudemtary testing yesterday and it looked like FetchXML was a little faster, but only by milliseconds.

    I agree that building the FetchXML string is a pain, but building a complex JSON URL can also be tricky.  I did find a free 2011 solution to help build the JSON queries, and you can build an advanced find and then export the FetchXML from within the CRM UI now.

    Probably a moot discussion, they both seem pretty fast. :)

    Tuesday, December 6, 2011 9:48 PM