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.
- Create a new ‘Multiple Lines of Text’ attribute. (Make sure the maximum length)
- 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.
After browsing the report, you can see image started appearing in the CRM Online Report.