I need to upload a profile picture for all my contacts in CRM online. Is it possible to bulk upload 4000 pictures?
*This post is locked for comments
I need to upload a profile picture for all my contacts in CRM online. Is it possible to bulk upload 4000 pictures?
*This post is locked for comments
I am using this code in a synchronous plugin that is triggered on Post Operation Update event of Contact Entity.
But every-time the plugin executes we are getting '2 minutes limit exceeded error'.
I am using WebClient to download the byte[] before setting it up in the image.
// TODO: Implement your custom Plug-in business logic.
IPluginExecutionContext context = (IPluginExecutionContext)localContext.PluginExecutionContext;
IOrganizationService service = (IOrganizationService)localContext.OrganizationService;
if (context.PrimaryEntityId != null)
{
Entity contactEntity = service.Retrieve("contact", context.PrimaryEntityId, new Microsoft.Xrm.Sdk.Query.ColumnSet(true));
if (contactEntity != null)
{
var webClient = new WebClient();
byte[] imageBytes = webClient.DownloadData("upload.wikimedia.org/.../220px-UPC-A-036000291452.png");
contactEntity["entityimage"] = imageBytes;
service.Update(contactEntity);
}
else
{
throw new Exception("Error");
}
}
Hi Hardik,
You can't do this through the browser but it's easy to do in the SDK. Here's are the details: [View:https://msdn.microsoft.com/en-us/library/dn511697.aspx:550:50]
For each of the contacts, retrieve them from CRM, set the entityimage property, and save it like this:
Entity contact = service.Retrieve("contact", contactId, new ColumnSet("contactid")); contact["entityimage"] = File.ReadAllBytes(theFilePath); service.Update(contact);
If this helps, I'd appreciate if you would mark this as the verified answer.
Thanks,
Aiden
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156