cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Maurits
Resolver III
Resolver III

How to display CDS attachment image?

Hi, hope somebody can help me. We add attachments like images to notes/annotations in the CDS.

There are great blogs on camera integration to do so. 

But I try to show the attached images in a PowerApp, which fails.

Found some blogs on how to show images from SharePoint lists attachments in a gallery, but somehow I can't get this to work with the CDS attachment. 

I receive the attachment.body with the textual content.

Is there a way to assign this to a image object or so?

 

Maurits

1 ACCEPTED SOLUTION

Accepted Solutions
Maurits
Resolver III
Resolver III

Solved it. FYI if someone else want to do the same:

Apparently the data stored with the attachments are not complete because the Canvas App used deletes the first part of it. Otherwise the result would't be usable jpg or png files.
When showing these files, the removed part of the text must be added first.
E.g. see code below when using the Notes entity.

 

Switch(
    Right(
        ThisItem.'File Name';
        3
    );
    "png";
    Concatenate(
        "data:image/png;base64,";
        ThisItem.Document
    );
    "jpg";
      Concatenate(
        "data:image/jpg;base64,";
        ThisItem.Document
    )  
)

View solution in original post

3 REPLIES 3
Maurits
Resolver III
Resolver III

Solved it. FYI if someone else want to do the same:

Apparently the data stored with the attachments are not complete because the Canvas App used deletes the first part of it. Otherwise the result would't be usable jpg or png files.
When showing these files, the removed part of the text must be added first.
E.g. see code below when using the Notes entity.

 

Switch(
    Right(
        ThisItem.'File Name';
        3
    );
    "png";
    Concatenate(
        "data:image/png;base64,";
        ThisItem.Document
    );
    "jpg";
      Concatenate(
        "data:image/jpg;base64,";
        ThisItem.Document
    )  
)
SamPo
Impactful Individual
Impactful Individual

I found another way of doing this. If you create a gallery and populate its items as 'Entity.Attachments' (you could also do a sub gallery of ThisItem.Attachments if you already have a gallery for entity items). Then add an image component to your gallery and set the 'Image' value to 'ThisItem.Value' (or just 'Value' if using a sub gallery). This works without any file manipulate.

Hi There,

 

It doesn't work for me. Is the thisitem.document contain the image?

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,892)