{"id":11986,"date":"2013-12-26T11:00:00","date_gmt":"2013-12-26T05:30:00","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=4"},"modified":"2013-12-26T11:00:00","modified_gmt":"2013-12-26T05:30:00","slug":"printing-entity-images-on-reports-in-dynamics-crm-2013","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2013\/12\/printing-entity-images-on-reports-in-dynamics-crm-2013\/","title":{"rendered":"Printing Entity Images on Reports in Dynamics CRM 2013"},"content":{"rendered":"<div dir=\"ltr\">\n<div><span><span><span>In our earlier post <span lang=\"EN-US\"><a href=\"http:\/\/inogic.blogspot.in\/2013\/09\/now-store-images-in-crm-2013.html\"><span>Now Store Images in CRM 2013<\/span><\/a> <\/span>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.<\/span><\/span><\/span><\/div>\n<div><\/div>\n<div>\n<p>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.<span style=\"line-height: 1.5;\">\u00a0<\/span><\/p>\n<\/div>\n<div><\/div>\n<\/div>\n<div><span><span>We could use the following code to read the image data using the CRM SDK.<\/span><\/span><\/div>\n<div><\/div>\n<div>\n<p>string binaryImageQuery =<br \/>\n@&#8221;&lt;fetch mapping=&#8217;logical&#8217;&gt;<br \/>\n&lt;entity name=&#8217;lead&#8217;&gt;<br \/>\n&lt;attribute name=&#8217;fullname&#8217; \/&gt;<br \/>\n&lt;attribute name=&#8217;entityimage&#8217; \/&gt;<br \/>\n&lt;\/entity&gt;<br \/>\n&lt;\/fetch&gt;&#8221;;<\/p>\n<p><span style=\"line-height: 1.5;\">EntityCollection binaryImageResults = _serviceProxy.RetrieveMultiple(new FetchExpression(binaryImageQuery));<\/span><\/p>\n<p><span style=\"line-height: 1.5;\">This would return the image data in binary format that we could then read in a byte array.<\/span><\/p>\n<p><span style=\"line-height: 1.5;\">But when you execute the same fetch query using BIDS for report designing, you receive the following results.<\/span><span style=\"line-height: 1.5;\">\u00a0<\/span><\/p>\n<\/div>\n<div><a href=\"http:\/\/4.bp.blogspot.com\/-3dD62eKnEK4\/UrpwkhJlqVI\/AAAAAAAACSc\/_lRgol20_2k\/s1600\/fetch.png\"><span><img decoding=\"async\" alt=\"\" src=\"http:\/\/4.bp.blogspot.com\/-3dD62eKnEK4\/UrpwkhJlqVI\/AAAAAAAACSc\/_lRgol20_2k\/s1600\/fetch.png\" border=\"0\" \/><\/span><\/a><\/div>\n<div><\/div>\n<div><span><span>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. <\/span><\/span><\/div>\n<div><span><span>Upon further review of the results we found that the System.Byte[] did not mean the binary data but only the string \u201cSystem.Byte[]\u201d. <\/span><\/span><\/div>\n<p><span><span><br \/>The Fetch query when executed using the RetrieveMultipe API as shown above returns binary data. But when the same query is executed using the <\/span><span lang=\"EN\">ExecuteFetch API call, the results are returned in xml format and therefore the image attribute returns only a string \u201cSystem.Byte[]\u201d not the actual image binary data in Base64 string.<\/span><\/span><\/p>\n<p><span lang=\"EN\">ExecuteFetchRequest fetch = new ExecuteFetchRequest();<\/span><\/p>\n<p><span lang=\"EN\">fetch.FetchXml = binaryImageQuery;<\/span><\/p>\n<p><span lang=\"EN\">_service.Execute(fetch);<\/span><\/p>\n<p><span lang=\"EN\">As a result of this, reports designed using FetchXML (reports in CRM Online) would not be able to include images on the report.<\/span><\/p>\n<p><span lang=\"EN\"><span>On-Premise installs can still add the images in the report using SQL queries.<\/span><\/span><\/p>\n<p><span lang=\"EN-US\">select<\/span><span lang=\"EN-US\"> con.FullName, con.Parentcustomeridname,con.entityimage\u00a0 fromFilteredContact con<\/span><\/p>\n<p><span lang=\"EN\">Bind the image control in the report to entityimage attribute<\/span><\/p>\n<div><a href=\"http:\/\/2.bp.blogspot.com\/-L3HS5Y9L0-g\/UrpxHPdxSGI\/AAAAAAAACSk\/qH5tUI6ofJ4\/s1600\/report_design.png\"><span><img decoding=\"async\" alt=\"\" src=\"http:\/\/2.bp.blogspot.com\/-L3HS5Y9L0-g\/UrpxHPdxSGI\/AAAAAAAACSk\/qH5tUI6ofJ4\/s1600\/report_design.png\" border=\"0\" \/><\/span><\/a><\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"line-height: 1.5;\">The result would be<\/span><\/p>\n<p><a href=\"http:\/\/4.bp.blogspot.com\/-YgIFUVDCOAA\/UrpxPc6RU5I\/AAAAAAAACSs\/WS7jng7Tqvg\/s1600\/report_result.png\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/4.bp.blogspot.com\/-YgIFUVDCOAA\/UrpxPc6RU5I\/AAAAAAAACSs\/WS7jng7Tqvg\/s1600\/report_result.png\" border=\"0\" \/><\/a><\/p>\n<p><span lang=\"EN\"><span>Hope this helps anyone trying to include images on reports.<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2013\/12\/printing-entity-images-on-reports-in-dynamics-crm-2013\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[21,22,24],"tags":[915,916],"class_list":["post-11986","post","type-post","status-publish","format-standard","hentry","category-dynamics-crm-2013","category-dynamics-crm-2015","category-dynamics-crm-2016","tag-image-data-type","tag-images"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/11986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=11986"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/11986\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=11986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=11986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=11986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}