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 / Variables in pdf file ...
Power Apps
Answered

Variables in pdf file name

(0) ShareShare
ReportReport
Posted on by 25

Hello everyone,

 

I'm doing my first steps in PowerApps and it seems I've decided to choose one of the most difficult problems 😉

 

I have a Sharepoint list with a PowerApp, including a pen input field. Thanks to Shane Young I have managed to save the pen input to pdf in my Sharepoint docs via html code (https://www.youtube.com/watch?v=RFZfvTuDmP0&t=338s

 

 

 

SubmitForm(Form2);;
PenInputToPDF_1.Run("<!DOCTYPE html>
<html>
<body>

<h1>Überschrift</h1>
<p>Nachname: " & DataCardValue9.Text & "
<img src=" & JSON(PenInput1.Image; JSONFormat.IncludeBinaryData) & ">

</body>
</html>" )

 

 

 

But what is driving me really crazy is that I can't find a solution for a variable file name. Please see the flow I used - sorry it is in German. The steps I used are Create File on OneDrive - Convert File (Preview) - Create File on Sharepoint - Delete File on OneDrive.

Flow.PNG

 

This works really fine, but of course I don't want each file to be named "test.pdf". How can I create a variable file name concatenated from 4 fields in my PowerApps form plus the current date+time?

This is my form

Form.PNG

 

Thanks for your help!

Berni

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    154,930 Most Valuable Professional on at

    Hi @MisterBurns ,

    Simply use “Ask in Power Apps” in the Flow field and it will become a parameter in the Flow  Run in Power Apps. You may have to delete and reconnect the Flow to pick up the new item and ensure you put .pdf on the end of the name in the Parameter.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • MisterBurns Profile Picture
    25 on at

    Hi Warren,

     

    thanks a lot, this already helped me, it seems to work.

    But what I am struggling now with is the name of the File. I used the following code on my PDF create button:

     

     

    Set(Surname_Filename; DataCardValue9.Text);;
    Set(Firstname_Filename; DataCardValue10.Text);;
    SubmitForm(Form2);;
    Corona.Run("<!DOCTYPE html>
    <html>
    <body>
    
    <h1>Überschrift</h1>
    <p>Nachname: " & DataCardValue9.Text & "
    <img src=" & JSON(PenInput1.Image; JSONFormat.IncludeBinaryData) & ">
    
    </body>
    </html>"; Concatenate(Surname_Filename; Firstname_Filename);;
    NewForm(Form2) )

     

     

    But whatever I try, I do not get the Surname and First name into the file name. I also tried the lines

     

     

    Set(Surname_Filename; DataCardValue9.Text);;
    Set(Firstname_Filename; DataCardValue10.Text);;

     

     

    in the OnChange events of the 2 text fields. The result is always the same, the file name is displayed as "True.pdf". And I can't open it, it seems to be the wrong format. When I change the file extension manually to html the file gets displayed. html would also be fine for me, but in my flow '.html' is not accepted in the concat part of the filename.

     

    Could you please advise once more?

  • WarrenBelz Profile Picture
    154,930 Most Valuable Professional on at

    @MisterBurns ,

    Assuming that your FirstName and Surname are in DataCardValue9 & 10, and the last parameter is the file name, you should only need this

    SubmitForm(Form2);;
    Corona.Run(
     "<!DOCTYPE html>
     <html>
     <body>
     <h1>Überschrift</h1>
     <p>Nachname: " & DataCardValue9.Text & "
     <img src=" & JSON(PenInput1.Image; JSONFormat.IncludeBinaryData) & ">
     </body>
     </html>"; 
     DataCardValue10.Text & DataCardValue9.Text & ".pdf"
    );
    NewForm(Form2)
    

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • MisterBurns Profile Picture
    25 on at

    @WarrenBelz 

    Your assumption is correct but I've tried this with the same result. Your code generates a file called '.pdf' which means that no value from DataCardValue9 & 10 is transmitted.

    File.PNG

    And the file itself seems to be corrupt, preview is not possible, even when downloading the file

    preview.PNG

    Using extension .html works for viewing the file and is acceptable for me. Nevertheless it would be interesting, why the pdf doesn't work. And why no values are transmitted. Any idea?

  • MisterBurns Profile Picture
    25 on at

    @WarrenBelz

    Found the solution for the file name finally:

    The DataCardValue.OnChange event is set to

    Set(varNN; DataCardValue9.Text)

    And the variable varNN is used in the html-part of the button then. This does what it's supposed to do.

    Only the pdf is not working yet but I'm fine with it as html is good as well.

     

    Thanks a lot for your help!

  • Verified answer
    WarrenBelz Profile Picture
    154,930 Most Valuable Professional on at

    Hi @MisterBurns ,

    Good to see - you will need to look at your Flow for the HTML to PDF issue.

  • MisterBurns Profile Picture
    25 on at

    Hi Warren,

     

    everything is fine now. The filename problem was solved as mentioned above by using variables.

    The pdf problem was indeed a mistake in the flow. I used the app's file content directly instead of the pdf created in Onedrive

    Thanks mate for your help!!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    with the new pdf button and ability I added Set(varPDFblob2, PDF('Screen12 Suggested Watering Schedule3')); SavePDFs.Run(DataCardValue2 &"SuggestedWateringSchedule3PDF.pdf",Substitute(JSON(varPDFblob2, JSONFormat.IncludeBinaryData),"""","") and this saved a screen shot of my powerapps screen to pdf to sharepoint with the name of the value of an ID (DataCardValue2) and the name of the screen "SuggestedWateringSchedule3PDF.pdf"

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard