Upload PowerApps Attachments to SharePoint Library Folder

Normally what happens is, you are uploading any document(s) in a SharePoint Document Library using PowerApps Attachment Control. But suppose in case, there is a requirement where you want to upload an attachment to the folder i.e. present in the SharePoint Document Library.

In this PowerApps Tutorial, We will discuss how to upload a PowerApps attachment to a SharePoint Library Folder. To achieve this, We will use Power Automate.

Also, you can check out the below link if you want to upload a PowerApps file to the SharePoint document library:

PowerApps Upload Attachment in SharePoint Document Library Folder

Scenario:

  • In this scenario, a user will upload an attachment by using the PowerApps attachment control and then the user will press the button.
  • When the user will click on the button, then the specific file will upload in the SharePoint Library folder (TSInfo Documents).

To workaround with this, you can refer to the below steps:

Step – 1:

  • At first, to add an attachment, you need to create a SharePoint Document Library and a folder within that. Refer to the below screenshot.
  • Here, Documents is my SharePoint Library name (its internal name is SharedDocuments) and TSInfo Documents is the Folder name that I have created here. Within this folder, the PowerApps file will upload.
Upload PowerApps Attachments to SharePoint Library Folder
Upload PowerApps Attachments to SharePoint Library Folder

Step – 2:

  • Next, Sign in PowerApps and create a blank canvas app with a tablet or mobile layout. On the PowerApps screen, add an Attachment control and a Button input as shown below.
  • Do you know how to add PowerApps Attachment control? If no, then follow the below tutorial:

Add PowerApps Attachment Control

Upload PowerApps Attachments to SharePoint Library
Upload PowerApps Attachments to SharePoint Library

Step – 3:

  • Now we will create a flow from the PowerApps. Go to the Action tab -> Power Automate -> Click on + Create a new flow as like below.
Add PowerApps files to SharePoint Library
  • Then go to My flows -> + New flow -> Select Instant cloud flow.
Add Power Apps files to SharePoint Library
Add Power Apps files to SharePoint Library

Step – 4:

  • Once you will click the new flow, then the below page will appear where the flow will start triggering in PowerApps. Just rename the flow name as Power Apps Upload File.
upload Powerapps files to SharePoint library using flow
upload Powerapps files to SharePoint library using flow

Step – 5:

  • Next, click on the + option and add a Create file action (in SharePoint). Enter the field values as like below:
  1. Site Address = Select or enter the SharePoint address name where the Document library is present.
  2. Folder Path = Select the Document Library name and as well as the folder name where you want to upload the PowerApps attachment.
  3. File Name = To specify the name of the file, go to the Dynamic content and then select Ask in PowerApps option. It will directly take the file name from the PowerApps itself.
  4. File Content = Similarly, to specify the file content, go to the Dynamic content and then select Ask in PowerApps option. It will directly take the file content from the PowerApps itself.

That’s it to do in the flow. Once everything is done, just save the flow and come back to the PowerApps.

power automate upload Powerapps files to SharePoint library

Step – 6:

  • On the PowerApps screen, click on the Upload Button -> Go to Action tab -> Power Automate -> add the flow (Power Apps Upload File) to the button that you have created recently as shown below.
power automate add Powerapps files to SharePoint library
power automate add Powerapps files to SharePoint library

Step – 7:

  • Once the flow is added to the upload button, then the below code will appear automatically in the Button’s OnSelect property as:
OnSelect = PowerAppsUploadFile.Run(

Where,

PowerAppsUploadFile = Flow name

  • Next, you need to specify the Attachment File name (.Name) and the File content (.Value) in the code. So below is the proper code that I have used on Button’s OnSelect property as:
OnSelect = PowerAppsUploadFile.Run(
    First(DataCardValue3_1.Attachments).Name,
    First(DataCardValue3_1.Attachments).Value
);

Where,

DataCardValue3_1 = PowerApps Attachment Control name

upload Powerapps files to SharePoint library using power automate

Step – 8:

  • Once everything is done, just Save and Preview (F5) the app. Attach a file using the Attach file option and then press the Upload button.
add files in SharePoint library using flow

Step – 9:

  • When you will press the upload button, then the flow will trigger and add the file in the SharePoint Document library folder.
  • If you will check the Flow run history, then you can see the flow has been succeeded as shown below.
power automate add files to SharePoint library
power automate add files to SharePoint library

Step – 10:

  • Go to the SharePoint Document Library (Documents) and open the existing folder (TSInfo Documents). Refresh the library, you can see the specific file has been uploaded in the folder as like the below screenshot. You can open your file from the library itself.
add powerapps files in SharePoint library using flow

Also, you may like these below PowerApps Tutorials:

This is how to upload a PowerApps attachment to a SharePoint Document Library Folder.

  • Hi Kumar,
    I created app exactly as described here and it works, but the file content after uploading to SharePoint become like this: appres://blobmanager/b6a7e56a5e914854b494787b620cc5c9/7

  • I’m having the same problem as Aleksey. The file this process creates is corrupted and cannot be opened. This does not work!

  • >