Tip #636: Use all attributes and miss some of the data

Entity imageLaziness is the engine of the progress. If it was not for Josephine Cochrane trying to avoid the house duties, we’d still be doing dishes by hand.

So we all guilty from time to time using all attributes when retrieving information from CRM. The consequences are not only spießrutenlaufen and eternal condemnation, but also dreadful performance and, as it turns out, missing information.

We learned from system job views, “all” does not always mean “all” in Dynamics CRM. It’s also true for fetchxml.

CRM will not return binary columns when all attributes are requested

That applies to entityimage attribute; the following fetchxml:

<fetch>
  <entity name="contact" >
    <all-attributes/>
    <filter>
      <condition attribute="firstname" 
	    operator="eq" value="Bruce" />
    </filter>
  </entity>
</fetch>

will not return the image itself.

This fetch, on the other hand, will:

<fetch>
  <entity name="contact" >
    <attribute name="entityimage" />
    <filter>
      <condition attribute="firstname" 
	    operator="eq" value="Bruce" />
    </filter>
  </entity>
</fetch>

Note that to retrieve image data using fetch you have to use RetrieveMultipleRequest instead of the deprecated ExecuteFetchRequest class. Latter will not return the image, whether you specify it or not.

Tweet about this on TwitterShare on Facebook0Share on Google+0

One thought on “Tip #636: Use all attributes and miss some of the data

Leave a Reply

Your email address will not be published. Required fields are marked *