Tuesday 9 June 2015

Updating EntityImage of CRM record

Hi,
 
Here is the code for updating the image(entityimage) of CRM record.
 
public static void UpdateEntityImageOfContact(IOrganizationService iService, Guid guidContact)
{
      byte[] byteArray = File.ReadAllBytes(@"CRM_Image.png");
      Entity entContact = new Entity("contact");
      entContact.Id = guidContact;
      entContact.Attributes["entityimage"] = byteArray;
      iService.Update(entContact);
}

Contact Record Before Update
 
 
Contact Record After Update

 
Hope this helps

--
Happy CRM'img
Gopinath.

2 comments:

  1. is there any change to get the Image_url directly from one crm instance and update the same picture in some other crm instance ?
    I have tried to update the same but when i retrieve the image_url and updating the same picture in some other crm instance but simply it is notupdating the picure..Could you please help me regarding the same.

    ReplyDelete
    Replies
    1. Hi,

      You need to convert the image to ByteArray and then use the same byte for updating.

      You cannot use the URL for updating.

      Delete