Opening Attachments from Power Apps instead of having to download.
Option 1 - View Mode Opening
In the example below, the Form is started in Edit Mode, showing a normal attachment control, however once it is switched to view mode, a different attachment list appears with an icon at the right that allows direct opening of the attachment with “one click”. If the file can be opened in a browser (images, PDFs) it will do so, otherwise it will download.
So what is going on here?
Firstly, a small limitation – the “view mode” list is actually a gallery (which cannot be inserted into the form), so is simply placed in the same location as the Attachment Control. Consequently, if the Form is longer than the screen, the gallery will not “scroll” with the form. The visibility of both controls is controlled by the form mode as shown further down.
The important piece is the Items of the “View” Gallery. If you simply reference the attachment control, you do not get the values you need, so you need to Lookup the SharePoint List with the relevant reference. I have simply used the ID of the selected item in the gallery from which the form was chosen, but this could be whatever identifier you wanted.
LookUp(
TestFields,
ID = galTest.Selected.ID
).Attachments
An additional function below is to shade alternate rows as shown in the demonstration – if you want to do this
With(
{
wList:
LookUp(
TestFields,
ID = galTest.Selected.ID
).Attachments
},
ForAll(
Sequence(CountRows(wList)),
Patch(
Last(
FirstN(
wList,
Value
)
),
{RowNo: Value}
)
)
)
Then the TemplateFill of the gallery is
If(
Mod(
ThisItem.RowNo,
2
) = 1,
White,
ColorFade(
LightBlue,
60%
)
)
Now the values of the controls in the gallery – the Label Text
ThisItem.DisplayName
And the Icon (it is an icon added to Media) OnSelect
Launch(ThisItem.AbsoluteUri)
The Visible of the Attachment Card is
frmAttachDemo.Mode=FormMode.Edit
and the Visible of the Gallery
frmAttachDemo.Mode=FormMode.View
and that is about the sum of it.
I have found it very useful in my SharePoint Integrated forms, (which are very basic user interfaces) that now allow one “double click” on the SharePoint item to open the form in View mode and then a further click to launch the form. This makes reviewing large numbers of daily submitted PDF and image forms much quicker.
Option 2 - Gallery with Images
If you have pictures in your attachments, you can view thumbnails of these in a gallery and then open the relevant item by simply selecting it. In the example below, the three attachment pictures are displayed in a horizontal gallery below the attachment control
As in the example above the Items of the Gallery are
LookUp(
TestFields,
ID = galTest.Selected.ID
).Attachments
The Image of the Image control is
ThisItem.Value
The OnSelect of the image is
Launch(ThisItem.AbsoluteUri)
Option 3 - HTML Control with Links
In the example below, the HTML Text box is inside the Attachment Control. It does not need to be, but may assist with placement and scrolling.
All items shown are hyperlinks and open the relevant attachments directly. The HtmlText of the box is
Concat(
LookUp(
TestFields,
ID = 1
).Attachments,
"<p><b><a href= '" & AbsoluteUri & "'>" & DisplayName & "</a></b></p>"
)
I hope this gives you some thought on the flexibility of Attachment controls and their usage.
Comments
-
Opening Attachments from Power Apps instead of having to download.
Option 3 was the simplest for us to implement. I show the "regular" attachments box when the form is being Edited (or New) and hide it when the form is being Viewed, and exactly the opposite for the HTML box.
Additionally, I appended "?web=1" to force attachments to open in the browser for quick viewing:
"<p><b><a href= '" & AbsoluteUri & "?web=1'>" & DisplayName & "</a></b></p>"Brilliant solution to a shortcoming that I would have thought Microsoft had handled by now. Thank you @WarrenBelz !
-
Opening Attachments from Power Apps instead of having to download.
I try this but its not working.
-
Opening Attachments from Power Apps instead of having to download.
This is more an issue with your browser settings as to whether you have a native app to open a file type. There is nothing in Power Apps you can change.
-
Opening Attachments from Power Apps instead of having to download.
I have a question regarding PowerApps form mode. When I add an attachment to the form and then switch to view mode, clicking on the attachment opens it in a new tab. However, PDF and image files open in view mode as intended, while Word documents and Excel files open in edit mode. I want all file types and documents to open in view mode when clicked on in a new tab.
-
-
Opening Attachments from Power Apps instead of having to download.
Can you please post all of this on the forum as it is the appropriate place for problem-solving discussions
-
Opening Attachments from Power Apps instead of having to download.
Hi, I am testing option with HTML textbox - there is no error visible but nothing visible in textbox
Concat(LookUp('Reklamace od zákazníků';ID = 1).Přílohy;"<p><b><a href= '" & AbsoluteUri & "'>" & DisplayName & "</a></b></p>")
Do I have any mistake in formula or in any form mode or etc? Thank you in advance for advice.
-
Opening Attachments from Power Apps instead of having to download.
Hello, I tried with another sharepoint list and there is no error message visible, but gallery is not showing images. I have still any mistake somewhere. I am trying solution 2 and 3.
If somebody could share how you reached this functipnality it would be appreciated.
Br
Jakub
-
Opening Attachments from Power Apps instead of having to download.
Hello, I would like to use procedure described above, but I have all the time error mesage in my formula. Could somebody describe a little bit more detailed what should be inserted instead of "Testfield" etc.
I am trying formula LookUp('Incident report';ID = Gallery1.Selected.ID).Přílohy but error is shown.
Thank you in advance for advice, because mentioned solution seems to be perfect.
Jakub
-
Opening Attachments from Power Apps instead of having to download.

Like
Report
*This post is locked for comments