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:
OnSuccess for Form1 executes the flow command:
Create a PDF control on your app. Update the Document Control:
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.
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:
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!!
I hope this example helps you.
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.
@AlanC in the post below (Read ALL of his input for pertinent info):
Solved! Go to Solution.
Thanks for sharing this.
Thanks for sharing this.
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.
The Super User program for 2022 - Season 2 has kicked off!
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.