cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stephenkln
Resolver I
Resolver I

Returning Value to PowerApps

Hey guys, 

 

I have a flow that takes HTML from PowerApps, creates a PDF in sharepoint and then is supposed to return the sharing link to that file back to my app. Everything is working except the last step, so I was hoping to get some help.

Here is my flow: 

stephenkln_0-1596723155435.png

stephenkln_2-1596723217932.png

stephenkln_4-1596723272667.png

The flow is executed onSelect of a button in PowerApps. Here is my formula to run the flow in powerapps:

 

Set(varShowSpinner,true);

If(Today()<>Max(FileNames,Date),Clear(FileNames),NoChange);

Collect(FileNames,{Id: CountRows(FileNames)+1, Date: Today(), Filename: "Health_Record_" & 'Employee List'.Selected.LastName & "-" & 'Employee List'.Selected.FirstName & "_" & 'Employee List'.Selected.EmployeeId & "_" & Today() & "_" & CountRows(FileNames)+1});

NewExportPDF.Run(HTMLHealthRecord.HtmlText,"Health_Record_" & 'Employee List'.Selected.LastName & "-" & 'Employee List'.Selected.FirstName & "_" & 'Employee List'.Selected.EmployeeId & "_" & Today() & "_" & CountRows(FileNames)+1);

Set(varDownloadLink,NewExportPDF.Run(HTMLHealthRecord.HtmlText,"Health_Record_" & 'Employee List'.Selected.LastName & "-" & 'Employee List'.Selected.FirstName & "_" & 'Employee List'.Selected.EmployeeId & "_" & Today() & "_" & CountRows(FileNames)+1));

Download(Text(varDownloadLink.download_link));

Set(varShowSpinner,false);
 
 
HTMLHealthRecord.HtmlText = var_HTML in flow -- and the rest = var_FileName
 
Again, everything seems to be working in the flow. I have tested it repeatedly. The PDF file is created in the appropriate folder and the sharing link is created in flow, but that url never seems to be passed back to PowerApps and nothing happens on the Download() portion of my code. Neither powerapps or flow are returning any errors.

I don't know how to resolve this. Any ideas?

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

For testing purposes I would try it with just a short filename in the var_fullfilename variable.  As I said, it works for me with the same steps.  The only difference I can see is that I'm not using a long concatenated file name.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

@Pstork1 I got it to work! You were right, it was the filename. Very strange behavior. I tried just changing the entire filename to a simple text string "Test". That failed with the same error. Then I tried changing the filename to:

Set(varDownloadLink,NewExportPDF.Run(HTMLHealthRecord.HtmlText,"Health_Record_" & 'Employee List'.Selected.LastName & "-" & 'Employee List'.Selected.FirstName & "_" & 'Employee List'.Selected.EmployeeId & "_" & Text( Now(), "mm/dd/yyyy hh:mm:ss" )).download_link);

This one worked. Not entirely sure why except it must like the timestamp at the end.

 

Thanks so much for your help! 

View solution in original post

10 REPLIES 10
Pstork1
Dual Super User III
Dual Super User III

Take a look at a recent run in the flow and look at the output of the last step.  Can you post a screenshot of a sample here?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 Looks like it's actually failing on the step where it creates the file in sharepoint:

stephenkln_0-1596726163646.png

Getting this error: 

A file with the name Root Folder/Sub Folder/Health_Record_Vader-Darth_231_8_6_2020_16.pdf already exists. It was last modified by i:0#.f|membership|REDACTED. on 06 Aug 2020 07:58:56 -0700.
clientRequestId: a97dbca1-dd12-4257-a82b-64a57fe1b80f
serviceRequestId: a97dbca1-dd12-4257-a82b-64a57fe1b80f

This doesn't make sense...there is no file in sharepoint prior to this step. This step creates the file in sharepoint. When I go to the sharepoint folder, the file is there...so I'm not sure how or why it's failing here.

Pstork1
Dual Super User III
Dual Super User III

Any chance the file is there from a previous test run and may still be in the recycle bin?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 Nope. Just tried again and made sure the recycle bin and the folder where the file is being created where both empty. Same error.

Pstork1
Dual Super User III
Dual Super User III

Let me try to duplicate your process and see if I can get it to work.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Pstork1
Dual Super User III
Dual Super User III

I think it might be a problem with the length of the filename you are using.  I seem to remember DOS having an issue with filenames where the differential in the names wasn't in the first 25 characters.  Since your row count is at the end you may be trying to crete multiple files that the file system doesn't consider unique names.  For now try moving the rowcount + 1 identifier to the beginning of the file name rather than the end.

 

The logic definitely works.  I did a quick POC with a simple HTML and short file name and it returned a sharing link without an issuse.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 Did not work unfortunately. Still the same error...😣

Pstork1
Dual Super User III
Dual Super User III

For testing purposes I would try it with just a short filename in the var_fullfilename variable.  As I said, it works for me with the same steps.  The only difference I can see is that I'm not using a long concatenated file name.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

@Pstork1 I got it to work! You were right, it was the filename. Very strange behavior. I tried just changing the entire filename to a simple text string "Test". That failed with the same error. Then I tried changing the filename to:

Set(varDownloadLink,NewExportPDF.Run(HTMLHealthRecord.HtmlText,"Health_Record_" & 'Employee List'.Selected.LastName & "-" & 'Employee List'.Selected.FirstName & "_" & 'Employee List'.Selected.EmployeeId & "_" & Text( Now(), "mm/dd/yyyy hh:mm:ss" )).download_link);

This one worked. Not entirely sure why except it must like the timestamp at the end.

 

Thanks so much for your help! 

View solution in original post

Pstork1
Dual Super User III
Dual Super User III

Glad you got it working.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,322)