Display entity image in your webresource in Dynamics 365/ CDS? Use entityimage_url instead of image content.

Follow Debajit’s Power Apps & Dynamics 365 Blog on WordPress.com

I was bit hesitant to write this blog to be honest as I thought it’s pretty mundane and must be quite known to everyone. And we had the same requirement for the customer. They wanted to show the entity image of a contact in a webresource.

The functionality as already implemented and I was just reviewing the code. However when I checked the code, I found there is quite a bit written to show the image.

  • The entityimage field of the account is queried to get the content
  • The whole content is then set using <image src=’data:image/png;base64,<content>’ />

Surprising it is but when I told them there is a better way to do it without querying the content and all, many seemed unware of it. Hence I thought this would be of help to someone faced with similar situation.

For entity image field, there is a separate field created called – “entityimage_url” which can be queried as well. Below is the WebAPI query to get the entity image of an account. Same can be used with any other entity.

https://powerappsforyou2020.crm.dynamics.com/api/data/v9.0/accounts(936B419F-9F4B-E111-BB8D-00155D03A715)?$select=entityimage_url

image

The final step is to set the image url in the src attribute of the image in webresource. And you can see it in your web resource.

image

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading