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
Solved! Go to Solution.
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:
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:
Best regards,
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,
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:
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:
Best regards,
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 😉
What about a PDF. It keeps asking me to save it first
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.
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
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.
User | Count |
---|---|
203 | |
106 | |
56 | |
52 | |
41 |
User | Count |
---|---|
274 | |
159 | |
88 | |
81 | |
56 |