May 102011

The CRMAttachmentImage control downloads on codeplex have been updated to include gif and webcam support that I talk about in a new article that includes some instructions that may be helpful.

A while back Christian asked about this image control I had in a screenshot on one of my posts. And while it was ok, it was far from being something I would throw into a production environment. It was a starting point. I am proud to say that I have put the Silverlight control on codeplex at It is in beta because I am still working on putting the buttons on the ribbon instead of in the control.

Contact Form - with Attachment Image Silverlight Control

** If anyone has any ideas for loading a file in JavaScript and sending it to the Silverlight control to load the data, I’m open to suggestions.

The image itself is stored as an attachment in the notes. This way the control is utilizing CRM and not an external system to handle the images. Simply put in order to use this your users will need to be able to read notes and create them. They will also need the "Customization > ISV Extensions" permission. If you are not seeing the images, and everything else is right, then try checking the permissions.

Instructions are posted on the codeplex site, but it is fairly straight forward to add to a form. First, you just upload the web-resource and create a text field to store the guid for the not (annotationid). It MUST BE ON THE FORM, but it does not need to be visible, and you probably don’t want to make it searchable. The web resource does require the id and type to be passed, and some additional parameters.

The parameters are separated by a pipe | instead of a comma. An example parameter is:

field=new_imageattachmentid|subject='Contact''s Image'|prefix='img-'

Check out the full parameter list at If you have any suggestions or comments, please let me know.

  57 Responses to “CRM Attachment Image for CRM 2011 Entities”

Comments (55) Pingbacks (2)
  1. This looks very similar to powerPhoto in Dynamics Marketplace. Have you looked at that solution by Power Objects.

    • Today was the first day I’ve seen it or heard about it. I’ve had this silverlight control in my demos since late February, there is an image of the control in a post I made on the 15th or March, which spawned some people asking me for the control. Like the PowerObjects control, my control supports drag and drop, has buttons to upload or remove (unlink), and is also restricted to png and jpg images. The real difference is I did not put it on Marketplace, I put it on CodePlex, I’m not offering support of the control (not that it is very complicated). You can take it and do what you want with it, you can change the code, the images, anything you want. What I want is some other people to step in to say how to support more image types, use the ribbon, etc. There is a community of good developers out there and I hope they contribute their ideas and methods that will help make this project be better.

  2. Hi,
    Thanks for the post. It was helpful to show the images on the contact form. Great work. Keep it up. Hope you will find the way to add an image from Ribbon. Wish you good luck.


  3. Is there any new verion?

    • Nag, yes there is. I double-checked the code and found some points that may have been causing the error you posted and corrected them. I would greatly appreciate it if you would try the newer version on CodePlex. If you continue to have problems, please do not hesitate to post them. Thanks!

  4. Hi Carlton,
    Thanks for the reply. Ok it seems you updated yesterday newer version on CodePlex. Let me try and get back to you. Thank you..

  5. Hi, I installed the newer version. its giving same result.

    Step 1)I added new “CrmAttachmentImage.xap” file in the Webresource.

    Step 2) on this step you mentioned the parameter as

    field=new_imageattachmentid|subject=’Contact”s Image’|prefix=’img-‘
    [here there is no quotations for new_imageattachmentid]

    Tested but it didn’t work. Then I thought you are missing the Quotations for the field (new_imageattachmentid). so I tried the following way also..

    field=’new_imageattachmentid’|subject=’Contact”s Image’|prefix=’img-‘
    [here i put the sing quotes for new_imageattachmentid]

    When i am trying to add the image, it shows on the form area but it will not add the image under notes though u save the contact.
    But still it’s giving the error. As soon as form is loaded showing the following error.

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC EA 2; MS-RTC LM 8; .NET4.0C; .NET4.0E; InfoPath.3)
    Timestamp: Tue, 24 May 2011 14:10:12 UTC

    Message: Unhandled Error in Silverlight Application An error occurred while processing this request. at System.Data.Services.Client.BaseAsyncResult.EndExecute[T](Object source, String method, IAsyncResult asyncResult)
    at System.Data.Services.Client.QueryResult.EndExecute[TElement](Object source, IAsyncResult asyncResult)
    at System.Data.Services.Client.DataServiceRequest.EndExecute[TElement](Object source, DataServiceContext context, IAsyncResult asyncResult)
    at CrmAttachmentImage.MainPage.OnRetrieveImageAttachmentsComplete(IAsyncResult ar)
    at System.Data.Services.Client.BaseAsyncResult.HandleCompleted()
    … etc.

    • NAG,

      It is because of the double-quotes. I need to fix it in the Parameters.cs

      It has:

      // Handle double '' s and convert them to single '
      if (i + 1 < text.Length && text[i + 1] == '\'') { i++; sb.Append(t); }

      and it should be:

      // Handle double '' s and convert them to single '
      if (i + 1 < text.Length && text[i + 1] == '\'') { i++; sb.Append(t); continue; // This is what is missing that is making it think your quotes were closed. }

      Sorry, I forgot to make it continue. Parameter parsing... .. .. .

      • Ok, I updated the source code and versions on codeplex. Also, didyou check the checkbox to “pass record object-type code and unique identifier as parameters?”

        • I checked the checkbox. Might be you uploaded again newer version. let me download and try again .. :(

        • Hi, i am currently experiencing the same issue. I select a picture but its not saved. I recieve the error message that’s posted above, checkbox is set. I am doing this with admin privileges. What am i doing wrong?

  6. good job… just what I needed! :) and thanks for the sourcecode a while back :)

  7. When i save the image then prompt me error, it seem can’t create note in MSCRM 2011. Any new solution?

    • What is the error? Does the entity you’re using have notes enabled? Do you have access to create notes? You could actually store the image in a memo field as long as it is encoded into a string.

  8. Good work….Working straight forward!

  9. Hello please tell me step by step what the parameters or the procedure of choice because it does not leave me, thanks

    • You can create a field on the entity called new_imageattachmentid. It stores the selection of the image from the notes. When you upload an image, it is stored in the notes. the field stores the selected image. Then add the field to the form and hide it.

      Then add the xap file as a web-resource, put it on the page, set the parameters to:
      field=new_imageattachmentid|subject=’Contact”s Image’|prefix=’img-‘

      Then check the box for passing the object id, etc.

  10. Hello Everybody,

    Is this supported for CRM Mobile? Is there an way to attach pictures using note attachements on CRM Mobile?

    Thank you

    • I have not tested it, and I would think it would not work. What is it you are trying to accomplish? Take a picture and have it link to a CRM entity from a mobile device? Are you using any 3rd party products like CWRMobility?

  11. Hello,

    I just downloaded the control and add it to the form. Everything is working when I am using the CRM on the server that it is installed via RD. But when I open the CRM from my computer at home or somewhere else, I can not see the image and can not save an image to a Contant. Nothing happens on those two events. I did not hide even the hidden field, an on save it is not populated with the ID for the Image. And on top of that I am not receiving any errors. So is there something else that I missed?

    Thank you in advance for the help.

    • Atanas, Do you see the control with the buttons? When you upload an image does it show the image then? Does it put the ID into the field or does it stay empty? Thanks – Carlton

    • What security roles do your users have, and what are the effective permissions for the Customization tab for them? They should have the following permissions:

      Customization > ISV Extensions
      Customization > WebResource > Read
      Core Records > Note > Create (Minimum: User)
      Core Records > Note > Read (Minimum: User)

      • Thanks to Qaisar at Maison Consulting, it may be important to remember that you need to use the full url, not ip for the web-resource to work properly. I will work on fixing that, but that should fix the improper loading.

        • Hi,

          I tried it but i am having similar issue like Atanas, the account i used is admin and the web-resource url is complete. i tried it on premise using VM and it is working but when i tried it from my computer at home or somewhere else, I can not see the image and can not save an image to a Contant. Nothing happens on those two events.

  12. Carlton,

    This is simply amazing and a great help! you are a star and keep up the good work. well done….i have downloaded the last version and followed the step you have mentioned and it work like silk :)

    Thanks a bunch!


  13. Hi,

    This is just what I am after, Thansk! However I seem to be having a similar issue as Atanas. Only the CRM Admin is able to view the images after they have been saved. If you view a record as another user from a different computer it does not display the image, just the name of the file in the drop down box.
    Even with the Administrator Role under my own login, it doesn’t show the images. Looks like a permission sort of issue, could be be the Owner user of the Silverlight XAP Webresource is only able to see the images??

    Any help would be great, I’m looking forward to the Ribbon Button controls!!


    • That is really strange. When I test it with other accounts on my deployment it works. Is your deployment a CRM Online deployment I’d love to look at it. Have you double-checked that the ISV extension permission is checked?

  14. Hi Carlton, I’m using your application to upload image to CRM. That’s very nice, thank you.
    I have a question, how to display all the pictures? Currently it only show one picture, need to select from the dropdown to show another one.
    Is it possible to display all the pictures?

    • Joy, I do not have something that does that, but I could do that and post it. Maybe one or a set of pictures with arrows to navigate through them?

      • My client’s requirement is display multiple pictures in one page. They want to print it out. So I’m trying to do this. Still struggling. If you could post it, that would be great!

  15. Hallo there
    Thanks so much for this really useful/cool application. I got it working with mimimal issues.

    The only thing that’s not working as expected, is when I add an image to the Notes area without using the upload button on the app, it does not become available for viewing by the app.

    Is it suppose to be able to do that?

    Thanks again.


  16. Hello.
    I installed the extensions exactly as you said but on contact form I see icon Instal MS Silverlight. However I have Silverlight (version 5.0) installed.

  17. Hello,

    I downloaded this useful tool. I can download the picture and I see it on the screen. However It does not create a note and when I exit from my form the image dissappears. I did the same thing as you said on this page.

    • Alper,

      I just updated the image control to work better with onPremise deployments. If you have done everything on the page, then it may be unable to find the REST Url, so I’d suggest downloading the latest version on codeplex (literally updated a few minutes ago) and trying it.


  18. Great solution, clients love it when I demo on my local machine, but I still can’t get it to work OnPremise. I initially can see the controls on the Form when I add to the Entity, then after publishing the controls disappear. I followed all the suggestions on permissions, etc. in this post so far. Is there a trick to where you place it on the form? Any one else been able to make this work OnPremise?

    • This has to do with the CRM server name not being the same as the host name you are accessing. What is the name of your CRM server in the deployment manager and what is the url..? Are they different? Also are you using the latest version. I made some changes in an effort to fix it and if it is not working I would like to know so that I can continue to try and fix it.

      • Hi Carlton,

        I have finally figured out why i am not able to save or see the images I have uploaded, its along the sames lines as the above comment. Our deployment for On-Premise has multiple port numbers assigned to it, when we first deployed we used http://crminstance:5555, however all of our staff just use the default 80 port (http://crminstance), you can only view and save the images using port 5555, if you use port 80 they dont display or save.
        I have the latest download from Codeplex but it doesnt seem to make a difference.
        Hope this helps

        • You could hard code the getServerUrl to use your root webservice url with the correct port. It is using the sdk’s context.getServerUrl to get the server URL. If you do hard-code it to use a specific url, then I would suggest not modifying the URL for the Outlook client that uses the local URL.

  19. I am having issues getting any image to display, I am trying to get the image show up for the account entity, not contact. The section where I put the web resource is completly blank except that I can right click for silverlight properties.

    Would this be a correct set of parameters?

    field=new_imageattachmentid|subject=Account”s Image’|prefix=’img-’

    field display name is : imageattachmentid
    attached file name is : img-Logo.bmp

    If I competly butchered this, then I apologize I am very novice at this but any and all help is appreciated.

  20. Hi Carlton,
    I am using this solution to display picture on the form which is working fine for me if I am on the server and accessing it, but when i access the same entity from my local machine, i can’t see the image ? I can see it is attached in Notes, but it doesn’t load the image in the image areas. It still shown me the upload and delete button but it doesn’t even save the new image or retrieve the old.
    I think its the problem with accessing the database ?

    How can i rectify that?

  21. I have added this solution to a form. Also i passed the parameters after added the Web Resource, But while dragging an image into the form and saved it, the image is not saving in notes tab.
    Also I have found two errors in my Silverlight application even after I have added all the dll’s. such as:
    * The type or namespace “Annotation” could not be found
    * The type or namespace “crmContext” could not be found

    Can u help me please??

  22. I implemented the instructions above, but it didn’t work. Just a blank section is showed without buttons, or error messages. The only indication is the right click that show the silverlight properties. What can would generate this situation?

  23. Hi! excelent post!
    I have an entity that has a look up to the entity with the image. I can show the picture in the entity with the look up, but first i have to save and refresh.
    What I want to do is show the picture when the look up change (onchange ), is this posible? How?

  24. Hello Carlton.
    1) I am trying to display image as you have showed above. But When i try move web resource into other tabs (other than Notes Tab) ,the field is invisible (web resource is invisible).
    2) When the web resource is in Notes Tab it is visible. and when i add an image save it, it prompts an alert that ” You Need to provide a value for.” and the form is not saved.
    3) I am trying to save the image in other form not in contact form. Is it OK?. Will your control work for other forms also.
    4) I want to show the image side by as you have showed it.

    Please Reply. Urgently I need your help to solve these problems…
    Waiting for Your Reply.
    With Regards and Thanks in Advance.

  25. Hi,

    I am facing the same problem of ibeluci. Can you please help me.


    Jan Mohammed

  26. Sounds like a great tool!
    But, I added it to my CRM, and when I add a picture I see it in the form. But nothing is saved! The picture disappears after sav & close.
    Any help?

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>