cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jharville
Helper V
Helper V

View Attachment From SharePoint List In PDF Viewer

 

Hello all,

 

I have a SharePoint List (@Maps) where each item has a "Title" and "Attachments" field. The "Title" field just holds the name of the item (which is in this case, a room), while the "Attachments" field holds 1 PDF file per item.

 

jharville_0-1637097712485.png

 

Inside my PowerApp, I have a screen ('MapsScreen') that has the following code for the Gallery:

 

jharville_1-1637097783272.png

 

When you click on an item inside 'BrowseGallery2', the PDF opens in a different tab (here is the code for the item's OnSelect):

jharville_2-1637097864512.png

 

The problem is that even though the image successfully opens in a different tab, it takes a long time to load and our stakeholders would prefer the image pop-up within the app, not in a different tab. They'd like all functions be located within the app, and not externally. 

 

I've tried different code inside the PDF Viewer to show an item's attachment (from the Gallery) when selected, but nothing seems to be working right now. I was confident the following code would do the trick but it's throwing this error. Would anybody be able to help? Thank you!

 

jharville_3-1637098124321.png

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

 

@sgtsnacks 

 

I actually found an alternate solution. Instead of using a regular SharePoint list to house my pdf files, I created a document library to house them, and then referenced the 'thumbnail' property in an Image control to pull up the PDF file in a popup! 

 

View solution in original post

5 REPLIES 5
sgtsnacks
Helper I
Helper I

Hi jharville,

 

You can reference the Attachment using the "Value" property as the Document property of the PDF Viewer.

 

sgtsnacks_1-1637100514291.png

 

Document = Gallery3.Selected.Value

 

 

Edit: To Clarify:

 

Gallery 1 (Left) is SharePoint List Items

Gallery 3 (Middle) are attachments

PDF Viewer is referencing the selected Gallery3 Attachment.Value

 

 

Hello and thank you for the response @sgtsnacks !

 

Unfortunately, I think my scenario is different. I don't have 2 separate galleries (1 for the SharePoint list items, and 1 other for solely the attachments). This is why your code under 'Documents' for the PDF Viewer won't work for my PDF Viewer (please see the screenshot below):

 

jharville_0-1637125023481.png

 

After I type in "BrowseGallery2.Selected." ... "Value" isn't a valid attribute to reference. 

 

jharville_2-1637125389692.png

 

I only have 1 gallery for that screen, and that gallery houses items from my @Maps - SharePoint list. And each item in my @Maps - SharePoint list has 2 columns: Title & Attachments.

 

jharville_1-1637125164980.png

 

 

 

 

@sgtsnacks 

 

I actually found an alternate solution. Instead of using a regular SharePoint list to house my pdf files, I created a document library to house them, and then referenced the 'thumbnail' property in an Image control to pull up the PDF file in a popup! 

 

@jharville hi , I'm interested to know how you what your alternative solution was. Can please share if you dont mind? Im running into the same issue at this time. thanks

YuYu2runrunrun
Frequent Visitor

Hi power apps folks, 

I have similar issues when the pdf preview only works for myself but not working for other users. I have a flow to run for pdf files but I was aiming to get ride of it since it caused some issues when package into a Solution and extract sometimes doesn't work. 

The solution for make all the pdf, word docx, doxt, pdf works. I use a dummy png image file to help get the right file path. then change the image ID to 0.

The key is to create a label, make the label text=Substitute(Substitute(LookUp("SPdocumentlibraryname",ID=the png dummy ID),"image file path,""),"/ID","/0/")

Then add the label text in the PDF Preview Document = If(Last(Split(gallery.selected.Filenamewith extension,".")).Result="pdf", labelname.Text &EncodeUrl(gallery.selected.Folder path & gallery.selected.filenamewith extension),

Substitute(gallery.selected.Thumbnail.Large,"transform/thumbnail","transform/pdf"))

Then hide the labletext field, change visible to false.

This solution works for any user whom has access to this Power App now.

Hope it helps.

Cheers,

 

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.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (4,129)