This seemingly appears a simple task to include images just as the images were picked up earlier from the notes entity and displayed on the report. But when we tried to do the same with the image attribute, we found that the image attribute is actually not stored the same way as the attachments.
string binaryImageQuery =
@”<fetch mapping=’logical’>
<entity name=’lead’>
<attribute name=’fullname’ />
<attribute name=’entityimage’ />
</entity>
</fetch>”;
EntityCollection binaryImageResults = _serviceProxy.RetrieveMultiple(new FetchExpression(binaryImageQuery));
This would return the image data in binary format that we could then read in a byte array.
But when you execute the same fetch query using BIDS for report designing, you receive the following results.
The Fetch query when executed using the RetrieveMultipe API as shown above returns binary data. But when the same query is executed using the ExecuteFetch API call, the results are returned in xml format and therefore the image attribute returns only a string “System.Byte[]” not the actual image binary data in Base64 string.
ExecuteFetchRequest fetch = new ExecuteFetchRequest();
fetch.FetchXml = binaryImageQuery;
_service.Execute(fetch);
As a result of this, reports designed using FetchXML (reports in CRM Online) would not be able to include images on the report.
On-Premise installs can still add the images in the report using SQL queries.
select con.FullName, con.Parentcustomeridname,con.entityimage fromFilteredContact con
Bind the image control in the report to entityimage attribute
The result would be
Hope this helps anyone trying to include images on reports.