Changing the default entity image on a specific entity in CRM 2013

Hi everyone,
ever had the question to change the default picture of an entity in CRM 2013, eg. Account?

Entity Image Contact Photo

We have some different options as we think about it, supported as unsupported, let’s have a closer look:
Supported ways?
1) Plug-in
2) Batch job
3) jQuery call in OnLoad
4) On-Premise only: altering the picture on disk would invoke a change for all entities

So knowing our options, let’s focus on a supported way like the plug-in. First attempt would be on altering the entityimage_url in the post-retrieve of account.
A colleague of mine did some attempts and got a first result in using an additional Update of the account record, so this works.

But hey, disk space is sometimes limited so are there any alternatives?
Yes, after debugging a bit the Retrieve message and the account JavaScript I came to the following conclusions:

1) Update the attribute entityimage_url works in post retrieve for a fraction of a second on the form
2) What happened? Seems there’s some built-in mechanism in the CRM proprietary JavaScript which overwrites the inserted URL:
if(!IsNull($v_0))if(!this.$42_1($v_0))$v_0.src=Mscrm.CrmUri.create(“/_imgs/ContactPhoto.png”).toString();else $v_0.src=Mscrm.CrmUri.create($v_0.src).toString();
3) So what if we create a dummy account, upload an image and retrieve the entityimage_url attribute value?
Well I found this value:
4) When we update the entityimage_url of the BusinessEntity in the Outputparameters of the plug-in, it seems to work!
Important is to add the Timestamp parameter, without it your inserted image gets overwritten again by the default CRM contact photo. Don’t ask me why :)

The content of the Timestamp parameter doesn’t seem to have direct influence:
also works…

So a short code snippet:
Account Image code cs plugin

The end-result:

Accounts Images

Have fun!

Share Button