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

View a specific pdf file from sharepoint library in powerapps

Trying to set by clicking on a button of page 1 in powerapps, it would like to the pdf file opening in yhe next page under PDF viewer. That specific file are store in sharepoint document library.

Anyone would be able to shed some insight om how that can be done? Thank you.
1 ACCEPTED SOLUTION

Accepted Solutions


@CuriousJ wrote:
Hi Brian,
I have below error when adding the variables to powerapps. Not too sure where I did wrongly. Pretty new to the powerapps and flow. Maybe you could share some insight. Thanks.

I have correct the code in OnVisible property on the second screen in the app as it should have actually referenced the original document file name and not "._dlc_DocIdUrl_Description" (my bad Smiley Frustrated). 

The correct code for the OnVisible property should in fact be as follows:

UpdateContext({ loading_v: true });
UpdateContext({
   pdf_v:  'PowerApps-GetPDFdocument'.Run(
               Concatenate( First( Split( selecteditem_v.Name, ".") ).Result, ".pdf")
               )

 });
UpdateContext({ loading_v: false })

The purpose of the "Split" function used in the code above is to remove the file name extension of the original document name and thereaafter replace it with a ".pdf" file extension name.

Hope that solves the issue you were experiencing.
I have updated that blog with the correct code as well.

View solution in original post

10 REPLIES 10
Community Support
Community Support

Hi @CuriousJ ,

Do you want to preview the PDF files stored in your SP Library?

 

If you want to preview the PDF files stored in your SP Library, I afraid that there is no direct way to achieve your needs in PowerApps currently. The PDF Files (or any other files) stored in a SP Library is required to authenticate, but if you want to preview PDF files in PDF Viewer control, the server that hosts the document must not require authentication.

Please check the limits in PDF Viewer control, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-pdf-viewer#limitations

 

As an alternative solution, I think the combination of PowerApps and MS Flow could achieve your needs. Please check and see if the following blog and video resources would help in your scenario:

https://masteroffice365.com/viewing-pdfs-from-sharepoint-within-powerapps/

https://www.youtube.com/watch?v=NTp77benqfQ

 

Please take a try with above solution, then check if it could help in your scenario.

 

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.

Don't seems to get this to work.

UpdateContext({ loading_v: true }); UpdateContext({ pdf_v: 'PowerApps-GetPDFdocument'.Run( Concatenate( selecteditem_v._dlc_DocIdUrl_Description,".pdf" ) ) }); UpdateContext({ loading_v: false }

Hi @CuriousJ ,

Please go to your flow's history, then check if the flow returns a proper PDF File content back to your app.

 

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.

@v-xida-msft 

 

I wrote that blog and I am curious how many App Makers out there tried the "hack" I used asa for me at least it appeared to work consistantly well with any PDF document I wanted to view based on that Flow.

 

Having said that, subsequent to writing that blog I have been working on an "awesome" demo app that amongst many other things demostrates a technique to view any PDF document in SharePoint in 100% totally supported ZERO HACK method <grin> by running a single Flow not multiple times for say each PDF document in a folder in a Document Library but just once for all PDF documents in that single folder. Based on the technique I leveraged in my upcoming blog, my personal personal opinion is that PowerApps team may well finally have a fully supported method to finally enable this functionality natively within PowerApps (if they not already working on it...).

 

A few weeks ago I posted a teaser / prototype demo of the type of functionality this demo app implemented with just one screen can do:

https://youtu.be/WkAw6QCbcKk

 

Watch this space - within the next 2 weeks latest.

 

Hi @CuriousJ,

 

Further to checking if the Flow did successfully run, should you find it didn't even attempt to run, I'd suggest removing that Flow from the app and then add it again and test again.

 

Please share your findings, perhaps I can help further with more details. 

 

Regards,

Brian

Hi Brian,
I have below error when adding the variables to powerapps. Not too sure where I did wrongly. Pretty new to the powerapps and flow. Maybe you could share some insight. Thanks.

Based on your screenshots it would appear the problem lies in your PowerApp and not with the Flow. I'd also suspect that there is nothing wrong with any of your code on the second screen.

 

I'll need to retest the code because the way in which I populated the rows in my own gallery was actually using a Flow that returned the "._dlc_DocIdUrl_Description" property of the document. In which case in the next couple of days I'll update that blog in the next few days that details the first Flow I used to populate my Gallery with the PDF documents stored on your SharePoint Library...  


@CuriousJ wrote:
Hi Brian,
I have below error when adding the variables to powerapps. Not too sure where I did wrongly. Pretty new to the powerapps and flow. Maybe you could share some insight. Thanks.

I have correct the code in OnVisible property on the second screen in the app as it should have actually referenced the original document file name and not "._dlc_DocIdUrl_Description" (my bad Smiley Frustrated). 

The correct code for the OnVisible property should in fact be as follows:

UpdateContext({ loading_v: true });
UpdateContext({
   pdf_v:  'PowerApps-GetPDFdocument'.Run(
               Concatenate( First( Split( selecteditem_v.Name, ".") ).Result, ".pdf")
               )

 });
UpdateContext({ loading_v: false })

The purpose of the "Split" function used in the code above is to remove the file name extension of the original document name and thereaafter replace it with a ".pdf" file extension name.

Hope that solves the issue you were experiencing.
I have updated that blog with the correct code as well.

View solution in original post

Thanks Brian!
It's working perfectly now. 🙂

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (5,819)