web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to display image in SSRS from attachments?

(0) ShareShare
ReportReport
Posted on by 35

Hi everybody,

I need to retrieve preview image in Attachment, but I don't know how.

42404082.png

I try to using DocuRef, DocuValue, ImageReference and DocumentManagement but all failed.

DocuRef docuRef;

select firstonly docuRef
    where docuRef.RefRecId  ==  hcmWorker.RecId;

DocuValue   docuValue;
        
select firstonly docuValue
    where docuValue.RecId == docuRef.ValueRecId;

ImageReference imageReference = DocumentManagement::getThumbnail(docuRef);
              
demoTmp.ImageStr = DocumentManagement::construct().getDisplayUrl(docuRef);
//container conImgRef = ImageReference::GetPackedBinaryData(docuValue.AccessInformation);

//demoTmp.Image   =  ImageReference::GetPackedBinaryData(imageReference.parmImageData()); //DocumentManagement::getThumbnailAsContainer(docuRef);
demoTmp.ImageStr = DocumentManagement::construct().getImageFrameUrl(docuRef); //DocumentManagement::construct().getPreviewUrl(docuRef);
demoTmp.ImageStr = DocumentManagement::construct().getPreviewUrl(docuRef);        
demoTmp.ImageStr = DocumentManagement::construct().getDisplayUrl(docuRef);

demoTmp.ImageStr = docuRef.originalFileName();

I got the result is 127.0.0.1:10000/devstoreaccount1/documents/CD15AC4E-xxxx-xxxx-xxxx-DB4B81xxxxxx and filemanagement/_t/cd15ac4e-xxxx-xxxx-xxxx-db4b81xxxxxx?access_token=eyJDb21wYW55IjoiVEhNRiIsIkhhc2xxxxxRva2VuIjoiODNWWlVDSzY5Q0wwZ0JwazA1OFM0TWpKdmpOVxxxxxNkS1M1R2ZRU3FyclJRXC92anNVYUs0WHAyNlpMc1xxxxA0Z1ZienpWSmg4XC9TcXQ2MVE2UxxxxxUGFydGl0aW9uIjo1NjM3MTQ0NTc2LCJxxxxxSWQiOjU2MzcxNDQ1NzYsIlZhbGlkVW50aWxxxxxcL0RhdGUoMTY0MTI2NzQ4MxxxxxcLyIsIkZpbGVJZCI6ImNkMTVhYzRlLTM1YzktNDIzNC05MmEwLWRiNGI4MxxxxxTUyOCJ9&ms-dyn-caid=95cxxxxx-xxxx-0000-3b8c-c09511xxxxxx

I don't know how to present in container for display image in SSRS.

I spend a lot of time, I can't do that. Please help or give any suggestion to me.

Thank you so much.

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at
    RE: How to display image in SSRS from attachments?

    Hi partner,

    Did you set the format for the fields correctly in SSRS, what issue are you facing now ? Is the result you are giving what is displayed in the field?

    Please start with: docs.microsoft.com/.../how-to-add-an-embedded-image

    docs.microsoft.com/.../add-a-data-bound-image-report-builder-and-ssrs

  • PST Profile Picture
    35 on at
    RE: How to display image in SSRS from attachments?

    Hi Will Wu,

    Thank you so much for your reply.

    I'm not using embedded images, but I want to retrieve images from the database in the attachment of Standard.

    I can retrieve Employee image / Company logo but I don't know how retrieve image from attachment.

  • PST Profile Picture
    35 on at
    RE: How to display image in SSRS from attachments?

    Hello,

    Could anyone help me?

  • Alex VN Profile Picture
    1,994 on at
    RE: How to display image in SSRS from attachments?

    Hi,

    I think if you have the image URL, then you can try to convert it to memory stream and then to base64str and add it as a image field for your report:

    System.IO.Stream        stream = File::UseFileFromURL(imageUrl);

  • PST Profile Picture
    35 on at
    RE: How to display image in SSRS from attachments?

    Hi Alex,

    Thank you so much for your reply.

    I try to use 'stream = File::UseFileFromURL(imageUrl);' and result is error.

    If I use url is filemanagement/_t/cd15ac4e-xxxx-xxxx-xxxx-db4b81xxxxxx?access_token=eyJDb21wYW55IjoiVEhNRiIsIkhhc2xxxxxRva2VuIjoiODNWWlVDSzY5Q0wwZ0JwazA1OFM0TWpKdmpOVxxxxxNkS1M1R2ZRU3FyclJRXC92anNVYUs0WHAyNlpMc1xxxxA0Z1ZienpWSmg4XC9TcXQ2MVE2UxxxxxUGFydGl0aW9uIjo1NjM3MTQ0NTc2LCJxxxxxSWQiOjU2MzcxNDQ1NzYsIlZhbGlkVW50aWxxxxxcL0RhdGUoMTY0MTI2NzQ4MxxxxxcLyIsIkZpbGVJZCI6ImNkMTVhYzRlLTM1YzktNDIzNC05MmEwLWRiNGI4MxxxxxTUyOCJ9&ms-dyn-caid=95cxxxxx-xxxx-0000-3b8c-c09511xxxxxx

    error is

    System.IO.PathTooLongException: 'The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.'

    If I use url is 127.0.0.1:10000/devstoreaccount1/documents/CD15AC4E-xxxx-xxxx-xxxx-DB4B81xxxxxx

    error is

    System.Net.WebException: 'The remote server returned an error: (404) Not Found.'

  • Alex VN Profile Picture
    1,994 on at
    RE: How to display image in SSRS from attachments?

    Hi,

    I think you are testing on a cloud hosted environment and the url seems to be a local one. Can you try to check if you access this url you can 127.0.0.1:10000/devstoreaccount1/documents/CD15AC4E-xxxx-xxxx-xxxx-DB4B81xxxxxx  download the filed?

    From Sandbox for attachment I think you will get a  blob URL instead so I think you can try to test with a public image URL hardcoded and check further.

  • PST Profile Picture
    35 on at
    RE: How to display image in SSRS from attachments?

    Hi Alex,

    I test on my VM (Created from VHD of Microsoft).

    I try to connect to 127.0.0.1:10000/devstoreaccount1/documents/CD15AC4E-xxxx-xxxx-xxxx-DB4B81xxxxxx on web browser, I found the error is "This XML file does not appear to have any style information associated with it. The document tree is shown below.", error message is "ResourceNotFound - The specified resource does not exist."

    I try to test with public URL image link, I can get the image on my SSRS.

    Do you have any idea?

  • Suggested answer
    Alex VN Profile Picture
    1,994 on at
    RE: How to display image in SSRS from attachments?

    Hi,

    I think your DB might be a restored one so the attachment is actually not there in the system so that's why you got the error. I would recommend you to test with a new file uploaded and can be previewed in the system or if can you can test it with your sandbox environment.

    Regards,

  • PST Profile Picture
    35 on at
    RE: How to display image in SSRS from attachments?

    Hi Alex

    Thank you for your response.

    My DB is original DB on Sandbox.

    I change image and upload a new file then error has still the same.

    Do you have any idea?

  • Alex VN Profile Picture
    1,994 on at
    RE: How to display image in SSRS from attachments?

    Hi,

    I think because the attachment is uploaded to a protected blob and the url you used is an internal link.

    You can try to use:

    DocumentManagement::getAttachmentPublicUrl(docuRef1). This will return a public url:

    filemanagement/_t/cd15ac4e-xxxx-xxxx-xxxx-db4b81xxxxxx?access_token=eyJDb21wY

    With this you need to append your environment url like below to get an public access link:

    abcdev.cloudax.dynamics.com/filemanagement/_t/cd15ac4e-xxxx-xxxx-xxxx-db4b81xxxxxx?access_token=eyJDb21wY

    Another way you can try is to use:

    DocumentManagement::getAttachmentStream(docuRef1). This will provide you with the stream object. I tested with my Cloudhosted environment and it is working as expected.

    Hope this will help.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 724 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 580 Most Valuable Professional

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 554

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans