Answered by:
Images in CRM 2013 Online Reports

Question
-
Hey All,
So I am aware that FetchXML cannot fetch images from image entity and so our reports cannot have the image associated with that record usign FetchXML.
But is there any other way of achieving this? I have a custom entity named new_student and each record has a picture of the student. Now I want to print an ID card for student and it should contain the picture of the student too. I am generating a report to print the ID card. Is there a way of introducing the picture in the ID card report?
Wednesday, May 28, 2014 10:49 AM
Answers
-
Hi Hamzak,
Not sure about the entityimage itself, but you can access Images through FetchXML in CRM Online by attaching them to notes.
The following code shows you how to access them:
<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0" > <entity name="contact"> <link-entity name="annotation" from="objectid" to="contactid" alias="Notes"> <attribute name="documentbody"/> <attribute name="subject"/> </link-entity> </entity> </fetch>
Then in your report you can reference the Notes_documentbody attribute in an image property, and set the image source to "Database".
If this has helped you, please mark as answer, or reply if you need more information. :)
~ Atomic Coder- Proposed as answer by Nathan Eccles Friday, May 30, 2014 11:29 PM
- Marked as answer by Hamzak Monday, June 2, 2014 10:15 AM
Friday, May 30, 2014 1:46 PM
All replies
-
Hi,
You might want to have a look here : http://blogs.technet.com/b/southasiamvp/archive/2013/12/24/guest-post-entity-images-in-dynamics-crm-2013-explored.aspx
- Proposed as answer by Andrii ButenkoMVP, Moderator Wednesday, May 28, 2014 11:05 AM
- Unproposed as answer by Hamzak Thursday, May 29, 2014 9:49 AM
Wednesday, May 28, 2014 10:58 AM -
So i use this Code:
string binaryImageQuery = @"<fetch mapping='logical'> <entity name='lead'> <attribute name='fullname' /> <attribute name='entityimage' /> </entity> </fetch>"; EntityCollection binaryImageResults = _serviceProxy.RetrieveMultiple(new FetchExpression(binaryImageQuery)); foreach (Entity record in binaryImageResults.Entities) { String recordName = record["fullname"] as String; String downloadedFileName = String.Format("Downloaded_{0}", recordName); byte[] imageBytes = record["entityimage"] as byte[]; var fs = new BinaryWriter(new FileStream(downloadedFileName, FileMode.Append, FileAccess.Write)); fs.Write(imageBytes); fs.Close(); }
and pass my fetchXMl query to string binaryImageQuery?
Wednesday, May 28, 2014 11:08 AM -
Plus I think it says that you cannot add Images using FetchXML? it is using SQL in the end to add entity image.Wednesday, May 28, 2014 11:24 AM
-
Hi Hamzak,
Not sure about the entityimage itself, but you can access Images through FetchXML in CRM Online by attaching them to notes.
The following code shows you how to access them:
<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0" > <entity name="contact"> <link-entity name="annotation" from="objectid" to="contactid" alias="Notes"> <attribute name="documentbody"/> <attribute name="subject"/> </link-entity> </entity> </fetch>
Then in your report you can reference the Notes_documentbody attribute in an image property, and set the image source to "Database".
If this has helped you, please mark as answer, or reply if you need more information. :)
~ Atomic Coder- Proposed as answer by Nathan Eccles Friday, May 30, 2014 11:29 PM
- Marked as answer by Hamzak Monday, June 2, 2014 10:15 AM
Friday, May 30, 2014 1:46 PM -
Thanks Atomic Coder.Monday, June 2, 2014 10:16 AM