Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Bulk upload profile pictures to contact entity

Posted on by 590

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

  • SyedAkhter Profile Picture
    SyedAkhter 45 on at
    RE: Bulk upload profile pictures to contact entity

    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");
                    }
                }

  • Verified answer
    Aiden Kaskela Profile Picture
    Aiden Kaskela 19,692 on at
    RE: Bulk upload profile pictures to contact entity

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans