web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / View Attachment From S...
Power Apps
Answered

View Attachment From SharePoint List In PDF Viewer

(0) ShareShare
ReportReport
Posted on by

 

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

 

 

 

Categories:
I have the same question (0)
  • sgtsnacks Profile Picture
    62 on at

    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

     

  • jharville Profile Picture
    on at

     

    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

     

     

     

  • Verified answer
    jharville Profile Picture
    on at

     

    @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! 

     

  • rodelski Profile Picture
    33 on at

    @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 Profile Picture
    13 on at

    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,

     

  • coombech Profile Picture
    6 on at

    @YuYu2runrunrun sorry to resurrect an old thread but I'm having the same issue as the OP. Can you please elaborate on your formula for the label? I get 'invalid argument type (Record). Expecting text instead' with that formula. This is my formula... 

    Substitute(Substitute(LookUp(Documents, ID= 13349),"/JOLTS Admin/JOLTS Logo",""),"/ID","/0/")

     Any guidance would be greatly appreciated.

  • rrm159 Profile Picture
    4 on at

    Hello,
    Were you able to solve it, i am having the same proble,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard