cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

How-To procedure on how to view a PDF file from Sharepoint inside a PowerApp

I wanted to thank those that posted help on how to view a PDF file within a Powerapp.  (See below for credit, where it is due.)  Since this is not an entirely intuitive procedure, and has a very confusing bug (my assessment), I wanted to provide a concise "how to" on this one.  

 

Source: Sharepoint attahment (variation for SP Library)

Method:  Show on attach, Using MS Flow

Limitations:  Example ONLY works to view a single PDF attachment.

 

My purpose for this specific example is to display a PDF as a "preview" before posting to a sharpoint library.  Variations of this method can surely be used to display multiple attachments, or if you wish to view a library file.  

 

Powerapps side (props to @AlanC😞

 

OnAdd control in Form1 of my app executes the submit of the form:

SubmitForm(Form1)

OnSuccess for Form1 executes the flow command:

ClearCollect(PDFContent, ECN_View_PDF.Run(Form1.LastSubmit.ID))

Create a PDF control on your app.  Update the Document Control:

First(PDFContent).pdffile

 

MS Flow side:

 

Then, we get into the flow.  ***NOTE*** the Attachment Content object has the "bug" i was referring too.  Be sure to note that below!

 

Also note, my use of a Variable (FileID) is becuase of the multiple file nature of the Get Attachments action.  Get attachment content MUST NOT be inside an Apply to each.  The Set Variable captures this for you, and lets you stay out of it.  Thus, this example only works with single attahcments.  If you have multiple attachments, you will only view one of them this way.  I'm sure with some more creativity, you can do this with multiples.

 

image.png

BE SURE YOU NOTE THIS

 

You MUST use the expression builder to convert the Get Attachment Content to Base64.  The expression DOES NOT SHOW this after you save!!!  I call this a bug.  This is what it looks like when you build it:

image.png

 

Note what happens after you save it, and reopen it (The expression is different!!!)  It only shows the Attachment Content object.  But, it is converting despite it now showing the expression.  This will NOT WORK unless you add the base64() as above.  This will frustrate you to no end if  you forget it at a later date!!

image.png

 

 

I hope this example helps you.

 

Other notes:

 

If you are trying to view a SP Library file, the process is similar... however, read the credits below to be sure and apply encodeUriComponent to your Get File action.  Another source of utter frustration if you do not do it.  Also note!!!  This command also DISAPPEARS in your action, like my example above.  Regardless, you MUST apply it, save the Flow, and you are good, despite the bug.

 

encodeUriComponent(concat('/TechnicalNotices/', triggerBody()['Getfilecontent_FileIdentifier']))

 

CREDITS!:

 

@AlanC in the post below (Read ALL of his input for pertinent info):

 

https://powerusers.microsoft.com/t5/Connecting-to-Data/How-to-open-sharepoint-PDFs-in-PowerApps/td-p...

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How-To procedure on how to view a PDF file from Sharepoint inside a PowerApp

Thanks for sharing this.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Community Support Team
Community Support Team

Re: How-To procedure on how to view a PDF file from Sharepoint inside a PowerApp

Thanks for sharing this.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

adaptivecruise
Level: Powered On

Re: How-To procedure on how to view a PDF file from Sharepoint inside a PowerApp

Really cool stuff.

I'm having trouble with your link to the original article by @AlanC. Is there some other way to get to it? Looks like a helpful read.

Daniel

Super User
Super User

Re: How-To procedure on how to view a PDF file from Sharepoint inside a PowerApp

Seems maybe the links changed with the new forum update.  I put it there so I could refer to it later if I needed too.  If I get some time, i might re-look agian, and fix it.  However, the "just" of it is in this thread.

adaptivecruise
Level: Powered On

Re: How-To procedure on how to view a PDF file from Sharepoint inside a PowerApp

Great. Thank you for your reply @martinav have a great week!

 

Daniel

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 254 members 6,494 guests
Please welcome our newest community members: