{"id":110958,"date":"2018-04-27T09:48:57","date_gmt":"2018-04-27T16:48:57","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/"},"modified":"2018-04-27T09:48:57","modified_gmt":"2018-04-27T16:48:57","slug":"howto-upload-return-file","status":"publish","type":"power-automate","link":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/howto-upload-return-file\/","title":{"rendered":"Walkthrough: Use Flow in PowerApps to upload files or return data tables"},"content":{"rendered":"
Since the release of the new Respond to PowerApps functionality this month, we’ve seen people ask about a few different scenarios. In this post we\u2019ll walk through two examples:<\/p>\n
The first step is to use the PowerApps trigger. For the first action, choose\u00a0Create File<\/strong>\u00a0from OneDrive for Business<\/strong>.\u00a0On the Create File action, in the File name, select Ask in PowerApps from the Add dynamic content menu. Then, in the File Content, do the same. Your action should look like this:<\/p>\n However, there is a problem with this approach. When PowerApps takes an image in encodes it in a dataURI<\/em>. However, the Create File expects its File Content parameter to be binary<\/em>. Thus, you will need to use an expression to convert from dataURI to binary. It should be: dataUriToBinary(triggerBody()[‘Createfile_FileContent’]).<\/p>\n Next, you will add an action to get the direct link of the file. Add the\u00a0Create share link<\/strong> action and pass in the\u00a0ID<\/strong>\u00a0from the\u00a0Create file<\/strong>\u00a0action. You will want to choose Link type of Direct and Link scope of Anonymous. Finally, you will add the Respond to PowerApps action. Add an output for File URL, and pass the Web URL into that output from the previous action. Now save the flow.<\/p>\n Next, go to your PowerApp and add go to your Camera control that will be taking the image. Go to the OnSelect of the Camera control and select the\u00a0Flow<\/strong>\u00a0button from the\u00a0Action<\/strong>\u00a0tab in the ribbon and add the flow you just created.\u00a0<\/p>\n You will modify this formula slightly in order to set the file URL to a variable that you can use on a different control: Set(FileURL,UploadfileandgetURL.Run(“test.jpeg”,Camera1.Photo).fileurl)<\/p>\n Finally, just use the variable you created (in the above example, it’s FileURL) on the Image control, and it’ll render the image inline.\u00a0Note: when this Flow runs from the PowerApp, it will use the connection of the user who is signed into PowerApps, so you should only be creating files in a folder that all app users have access to.<\/em> With these few steps, you were able to build a PowerApp that uploads a file to OneDrive and then displays that file!<\/p>\n Another scenario that is now possible is to use a flow to get a table of data — either from SQL, Excel, or another data source. The simple\u00a0Respond to PowerApps<\/strong>\u00a0action only allows you to return back basic strings of data. However, for more advanced users, we do have a way to return a full Table of data by building a JSON schema.<\/p>\n Once you have the PowerApps trigger and your action that returns a table (in this example,\u00a0List rows present in a table<\/strong>), you will add the\u00a0Request – Response\u00a0<\/strong>action to the end of your flow. You can leave the Status Code and Headers options as-is, and then in the\u00a0Body<\/strong> you’ll want to pass the whole table of data (not just a particular field). To do this, in the Add dynamic content select\u00a0Show more<\/strong>\u00a0and you should see the outputs from that action – you’ll want to include the List.\u00a0<\/p>\n Now you should save your flow. However, unlike when you use the Respond to PowerApps you’re not done yet — you will also have to get the JSON Schema<\/em> for your response to send to the PowerApp. The easiest way to do this is to:<\/p>\n You should now see the schema of your table in the Response<\/strong> action. Save your flow again.<\/p>\n Now you’re ready to add your flow to your PowerApp, and use it like you would use any other Table of data in your PowerApp.<\/p>\n","protected":false},"excerpt":{"rendered":" This month we released new “Respond to PowerApps” functionality. In this post, we\u2019ll walk through examples of two scenarios: uploading, and then displaying in the PowerApp, images stored in OneDrive for Business (or other cloud locations), and, returning a Table of data back to a PowerApp (such as from a SQL query or Excel workbook).<\/p>\n","protected":false},"author":347,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","power-automate-category":[2836],"power-automate-tag":[],"coauthors":[2913],"class_list":["post-110958","power-automate","type-power-automate","status-publish","hentry","power-automate-category-walkthroughs"],"yoast_head":"\n<\/p>\n
<\/p>\n
<\/p>\n
<\/p>\n
Returning tables of Data<\/h2>\n
<\/p>\n
\n
\n<\/li>\n
\n\u00a0<\/li>\n<\/ol>\n