This month, I had a requirement to display images for Dynamics CRM’s entity records in SSRS report. The requirement looked very straightforward to me as I have implemented in the past a similar requirement in Dynamics CRM On-Premise environment using SQL query based SSRS report. But to my surprise, all approaches I was thinking failed due to Sandbox limitation in Dynamics CRM Online environment.

While doing this exercise, I didn’t find any collective information which talks about these pain points, so I thought of putting down my learning together for others’ benefit.

Approach 1

At first, I created image attribute on required entity. My plan was to use this image attribute to store image for entity record and display image on report using FetchXML.

approach1 contact information

 

As per plan, I added image control on SSRS report and bound it to FetchXML image attribute.

fetch xml image attribute

 

After executing report, I received below error in Visual Studio.

visual studio error icon

error list visual studio

 

After further debugging, I realized that FetchXML after execution does not return actual image binary data in Base64 string. It only returns string “System.Byte[]”. Due to this, image control is not able to render actual image.

Approach 2

Next, I decided to use Dynamics CRM web resource to display image in SSRS report. I tried both relative and hardcoded url for web resource, but both options didn’t work.

Final Solution

Finally, I was able to display the image into SSRS report using Notes attachment. Please find steps below:

  1. Attach image to note.

approach2 activities notes

  1. Create dataset in FetchXML to retrieve notes with images.

fetchxml dataset

document body

 

  1. Drop image control on SSRS report.
  2. Set source as Database.
  3. Set MIME type as per your requirement. (PNG,JPG etc..)

image properties

 

  1. Deploy and execute report in CRM online.

display image ssrs fetchxml report

 

Finally, it worked! 🙂 🙂 🙂

Hope you find this helpful.