cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
alunhughes
Frequent Visitor

Open SharePoint List Attachment from PowerApps

Hi,

 

I've created a PowerApps form using a SharePoint list and used the Attachment column. My form uploads the attachment to the SharePoint list with no problems (I only want to include max 1 attachment per list item).

 

I want to be able to open the attachment from an icon used within a gallery (open in browser is more than sufficient) so was thinking along the lines of the Launch() feature and construct a URL for the location of the attachment (i.e https://MY-TENANCY/sites/SITE-NAME/Lists/LIST-NAME/Attachments/{ID}/{ATTACHMENT-DISPLAY-NAME})

 

I see an attachment display name as a control but not sure how to construct the string for this command.

 

Can any one help?

 

Many thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @alunhughes ,

Do you want to open the Attachment (single one attachment) via pressing the icon in your Gallery?

 

Based on the needs that you mentioned, I think it is not necessary to construct a URL string for the location of the attachment of a SP List Item.

 

I have made a test on my side, please consider take a try with the following workaround:

6.JPG

 Add a Icon within your Gallery, set the OnSelect property to following:

Launch(First(ThisItem.Attachments).AbsoluteUri)

Note: The First(ThisItem.Attachments).AbsoluteUri formula would return the URL of the attachement file of a SP List Item.

 

In addition, if you want to force attaching only once file to each SP List Item, please consider set the Max attachments property to 1 as below:

7.JPG

 

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.

View solution in original post

8 REPLIES 8
ricardosanchezm
Advocate II
Advocate II

Hi @alunhughes ,

If you are using a gallery to open the attachment in a web browser you can do the following.

Launch(Concatenate(GalleryName.Selected.AbsoluteUri;"?web=1"))

 It will get the full path of the attachment and concatenate the string "?web=1" to open it in a new browser tab.  I have a gallery with a list of attachments with this command and works perfectly.

Regard,

v-xida-msft
Community Support
Community Support

Hi @alunhughes ,

Do you want to open the Attachment (single one attachment) via pressing the icon in your Gallery?

 

Based on the needs that you mentioned, I think it is not necessary to construct a URL string for the location of the attachment of a SP List Item.

 

I have made a test on my side, please consider take a try with the following workaround:

6.JPG

 Add a Icon within your Gallery, set the OnSelect property to following:

Launch(First(ThisItem.Attachments).AbsoluteUri)

Note: The First(ThisItem.Attachments).AbsoluteUri formula would return the URL of the attachement file of a SP List Item.

 

In addition, if you want to force attaching only once file to each SP List Item, please consider set the Max attachments property to 1 as below:

7.JPG

 

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.

Thank you both for your help.

 

This is exactly what I need - a much simpler way using the AbsoluteUri (which I was unaware of). I had already set the max attachments to 1 🙂

 

Thanks

Hello everyone. In case you still have questions on the topic, we go through this in some more detail.

Display SharePoint List Attachments in PowerApps (2019)

 

The .AbsoluteUri requires the user to be logged into the SharePoint front-end (which is not always the case obviously), while .Value uses the SharePoint connector to fetch the attachment(s) so this is a better option.

 

Dawid van Heerden

Follow on Twitter: @davestechtips

Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1

**If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions. AND we get points for it 😉

gatafish
Frequent Visitor

What about a PDF. It keeps asking me to save it first

 

sahrastolz
Frequent Visitor

Has the AbsoluteUri method of launching an attachment stopped working? I had it going successfully in 2021 but now it's started throwing an error. Not sure whether something's changed on my end or Microsoft's.

alunhughes
Frequent Visitor

Hi @sahrastolz

I've only implemented it once (back when I had the above issue). Following your comment yesterday I checked my app again this morning and it still works as expected (no changes to the code for 2+ years).

 

What are the problems your having?

 

Thanks,

Alun

Hi Alun, thanks for your reply.

 

I'm sure that I had the attachments loading from a collection, but I've also found that attachments and collections don't mix very well so I've fixed my problem by using a lookup to load the attachment directly from the datasource.

The error was with the code as follows.

Launch(First(LR_Review_Gallery.Selected.Attachments).AbsoluteUri)

The error message was "The function 'First' has some invalid arguements".

I've replaced the above with

First(LookUp(LeaveDatabase,ID=LR_Review_Gallery.Selected.ID).Attachments).AbsoluteUri

and it seems to be working again.

Thanks for your speedy reply!

Sahra

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,185)