Showing picture(entityimage) into CRM Online Report

Author: Zohaib Uddin Khan

Credit: For this tip & trick, thanks to Andrew Butenko

I need to prepare a CRM Online report which shows the picture of the \’Contact\’ or any other entity. The schema name for the picture attribute is \’EntityImage\’. Since I\’m preparing the report for the CRM Online, so I can only use FetchXML. I used the \’EntityImage\’ attribute in the FetchXML as I used other attributes but a picture is not appearing. Further analyzing the \’EntityImage\’, I noticed that it is only returning the string data while I was expecting binary data into it.

At this point, I posted my question to the \’Dynamic CRM\’ community and Andrew Butenko provided a solution to handle this case.

Solution:

  • Create a new \’Multiple Lines of Text\’ attribute. (Make sure the maximum length)

\"EntityImage-CRM-Online-Report-1\"

  • Write an Update Plugin on the Contact entity, which will store the value in Base64. No need to write a Create plugin as a picture can only be set after the creation of the record. Following one line will convert the data of \’EntityImage\’ into \’Base64\’ string.

entity[\”cewa_entityimagebase64\”] = Convert.ToBase64String((byte[])entity[\”entityimage\”]);

  • Now, open the Report, place the image placeholder and set the values accordingly. The following line of code will do the trick.

System.Convert.FromBase64String(Fields!cewa_entityimagebase64.Value)

\"EntityImage-CRM-Online-Report-2\"

After browsing the report, you can see image started appearing in the CRM Online Report.

\"EntityImage-CRM-Online-Report-3.png\"

2 thoughts on “Showing picture(entityimage) into CRM Online Report”

  1. Hi, great idea to add custom field and write there value from image field. I’ve tried use ootb entity image field in d365 online but Reporting Service cannot render picture so I used document templates.
    Regards,
    Michał

Leave a Comment

Your email address will not be published.