cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CoriY
New Member

CDS Attachments -- Download/Open in new window from app

I've been searching for a while and can't seem to find a solution.

 

I have an app with a gallery that's currently connected to a Sharepoint list. Each item in the SP list has one attachment. Clicking an item in the gallery will open that attachment in a new window.

 

I'm changing the data source for this gallery to a CDS entity, but I can't figure out how to keep the functionality of opening the attachment in a new window (or downloading it). How do I do this?

2 REPLIES 2
GarethPrisk
Resident Rockstar
Resident Rockstar

You can try the File field type: https://docs.microsoft.com/en-us/powerapps/maker/common-data-service/types-of-fields#file-fields

 

This will count against your File storage, as opposed to entity records (is my understanding at least). It also assumes you want a single record/row in CDS, per file. If you need multiple files per record, then this approach still works (albeit, as a child record).

 

It has some advantages over the OOB Note entity and attachments

  • Independent security; otherwise it's Note-based and many orgs want Read Org, or even Write Org
  • Extensible metadata
  • Easily surfaced in Canvas app as a Form Data Card
  • Can load/create Files via Canvas app

It has some disadvantages, currently

  • Cannot be displayed in a model-driven app (yet), but can in Canvas
  • Cannot be interacted with in a model-drive app without a PCF control, or embedded Canvas app

Field field on a Form controlField field on a Form control

Patching it is possible as well, something like this:

Patch(
        EntityName,
        {
            new_name: app_Name,
            new_FileField: {
                FileName: Concatenate(
                    Text(app_Name),
                    ".png"
                ),
                Value: app_hsl_file
            }
        }
    )
v-xida-msft
Community Support
Community Support

Hi @CoriY ,

Could you please share a bit more about the Attachment attached to your CDS Entity? Image file? PDF File?

Do you want to preview the attachment of an Entity record within a new window through Launch function?

 

Based on the needs that you mentioned, I afraid that there is no way to achieve your needs in PowerApps currently. When you attached file as attachment to a Entity record, the attachment files are actually stored within the Notes Entity.

Please check and see if the following thread would help in your scenario:

https://powerusers.microsoft.com/t5/Common-Data-Service-for-Apps/How-to-access-the-Content-stored-in...

 

The result the First(ThisItem.Attachments).Value formula or the First(ThisItem.Attachments).AbsoluteUri formula returned is not a valid web resource, so you could not use Launch or Download function to preview it in new window or download it.

 

If you would like this feature to be added in PowerApps, please consider submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,580)