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

Report Server has RDLSandboxing enabled

Today, while uploading a report in the Dynamics 365 Online, I faced the following exception:

Report-Server-RDLSandboxing-Enabled

After clicking on the ‘Download Log File’ button, I got a more detailed exception and it informed me that ‘Microsoft.VisualBasic.Interaction’ has been referred which is not allowed in the Dynamics 365 Online (seems reasonable).

Report-Server-RDLSandboxing-Enabled-1

Since I was not exactly sure at what places I used it nor how many times were it used, so I opened the *.rdl file into Notepad++ and do the Find and replace. In this way, I removed all the instances of Microsoft.VisualBasic.

Report-Server-RDLSandboxing-Enabled-2

After removing the references to Microsoft.VisualBasic, I upload the report and it works properly. Bingo!!