cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MarrinerDev
Advocate III
Advocate III

HowTo: Respond to PowerApp with dynamic file?

I am building a Flow to query data from Azure SQL and would like to return that data as a CSV file to a PowerApp.

 

Basically, there is a button on the PowerApp which says something like "Generate Report". When a user clicks on it, I would like the Flow to run, return the dynamically generated CSV file and the browser to open the file directly or "Save As" dialog (don't care which). Basically I want the button to behave as if it was just linking to an existing CSV file.

 

I have gone through the steps to generate CSV data from the SQL result set data, that's easy enough. But now I want to return the dynamic CSV file to a PowerApp.

 

What I'm not sure is how to return a "file" from a stream to a PowerApp (I don't want to create a temporary file on OneDrive/SharePoint and return a link to that because it involves clean-up and security issues I won't go into here).

 

I'm not sure how to use the "Response" action to achieve this i.e. set headers, MIME type correctly, format the return data (do I need to call something like dataUriToBinary etc)

 

There is also the "Respond to a Power App or Flow" action which includes a return type of "File" but of course the documentation doesn't exist to actually show how to use it correctly or even if it will achieve what I want. When I tried it from the PowerApp, the app thought the return type was "record" not a file stream.

 

The other question of course is how to receive the file on the PowerApp side. i.e. The Download() and Launch() functions expect URL strings, not file streams, so I'm not sure how to create our desired behaviour.

 

Many thanks for any help or examples you can point me to.

1 REPLY 1
v-xiaochen-msft
Community Support
Community Support

Hi @MarrinerDev ,

 

Firstly, powerapps cannot display/handle blob data type.

So, if you want the show something in your canvas ,e.g. image, you need a base64/datauri or url instead of blob.

If you want to open your csv file or download your csv file, the url is the only method because download and launch function only support url parameter.

 

Best Regards,

Wearsky

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (2,652)