Inogic is a hub of like minded professionals who believe that innovativeness is the key for providing the most optimum solutions in the SME segment.We are committed to putting our time and efforts to Research and Develop on Dynamics CRM so that you can be benefited by the cutting edge methodologies. We endeavor to share some of our work on this blog by introducing Tips, Tricks and products from our labs.
In our earlier post Now Store Images in CRM 2013 we discussed at length about the new Image attribute added to CRM 2013. It included steps to programmatically read/write to this field. The next step being the ability to include the image attribute in the reports.
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.
We could use the following code to read the image data using the CRM SDK
string binaryImageQuery =
<attribute name='fullname' />
<attribute name='entityimage' />
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
This appears all good but when you set the control source of the image control on the form to the entityimage attribute, it returns an error about the data in the field not being in correct format.
Upon further review of the results we found that the System.Byte did not mean the binary data but only the string “System.Byte”.
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
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 from FilteredContact 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.
Posted by: Inogic
For more information/discussions (documents, sample code snippets, detailed work flow or diagrams)
Please be free to visit the following links or email us:
Other Microsoft Sites
I'm a Customer
I'm a Partner
Follow Microsoft Dynamics