Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Import Pictures to Entity Image filed CRM

Posted on by Microsoft Employee

Hi,

I want to import a couple of hundred pictures to different records in the Product entity in CRM. I figured there must be a way to do that using my image path and the Product ID in CRM, and then connect it to the field Entity Image on the Product entity. This field is not visible when I am trying to import data. Neither is it visible on the form, how come since I would assume it is by default on the form since I can add the pictures manually. 

Any ideas? 

Thanks!

/Isabell 

*This post is locked for comments

  • Suggested answer
    Felippe Profile Picture
    Felippe 796 on at
    RE: Import Pictures to Entity Image filed CRM

    You can dev a batch using the CRM SDK to solve this:

    First get the entitycollection of Products and do a list of correspondent path string.

    Iterate the entitycollection passing the pair <Entity record, path>

    /// <summary>

           /// Receive the entity record and the path of file

           /// </summary>

           public void UploadPhoto(Entity _entity, string path)

           {

               try

               {

                   Image photoContato = Image.FromFile(path);          

                   _entity["entityimage"] = ImageToByteArray(photoContato);

                   _service.Update(_entity);

               }

               catch (Exception ex)

               {

                   Console.Writeline(ex.Message + "\n" + path);

               }

           }

    public static byte[] ImageToByteArray(System.Drawing.Image image)

           {

               using (var ms = new MemoryStream())

               {

                   image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);

                   return ms.ToArray();

               }

           }

    If this solves please "Like" and mark as "Verified Answer"

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans