Have you ever uploaded any file to SharePoint Document Library using Power Apps? If not, no worries!
This Power Apps tutorial will assist you with how to work with Power Apps Upload File to SharePoint Document Library with various examples.
Power Apps Upload File to SharePoint Document Library
In this scenario, a user will upload an attachment by using the Power Apps attachment control, and then the user will press the button.
When the button is pressed, the specific file will upload to the SharePoint Library folder (TSInfo Documents).
To workaround with this, you can refer to the instructions below:
1. Create a SharePoint Document Library and a folder to add an attachment. Refer to the screenshot below.
2. My SharePoint library is called Documents (internally, SharedDocuments), and the folder I made here is called TSInfo Documents. The Power Apps file will be uploaded to this folder.
3. Next, Sign into Power Apps and create a blank canvas app with a tablet or mobile layout. Add an Attachment control and a Button control on the Power Apps screen, as shown below.
NOTE:Check out this complete tutorial to learn how to add and use Power Apps Attachment control.
4. Now, we will create a flow in Power Apps. Go to the Power Automate tab [from left navigation] -> Create new flow -> Click on + Create a flow as shown below.
5. The below Power Automate page will appear where the flow will start triggering in Power Apps (V2). Just rename the flow name as .
6. Next, click the + New step button and add a Create file action (in SharePoint). Enter the field values as like below:
|Site Address||Select or enter the SharePoint site address where the Document library is present.|
|Folder Path||Select the Document Library name and the folder name where you want to upload the Power Apps attachment.|
|File Name||To specify the file’s name, click the Dynamic content -> Select Ask in PowerApps option. Power Apps will then directly take the file name from itself.|
|File Content||To specify the file content, select the Dynamic content -> Select Ask in PowerApps option. It will directly take the file content from the Power Apps itself.|
There is nothing else to do in the flow. When finished, save the flow and return to the Power Apps app.
7. On the Power Apps screen, click on the Upload Button -> Go to the Power Automate tab [from left navigation] -> Add flow -> Select Power Apps Upload File that you created recently.
8. 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(
PowerAppsUploadFile = Flow name
9. Next, 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:
OnSelect = PowerAppsUploadFile.Run( First(DataCardValue3_1.Attachments).Name, First(DataCardValue3_1.Attachments).Value );
DataCardValue3_1 = PowerApps Attachment Control name
10. Save and Preview (F5) the app once everything is done. Attach a file using the Attach file option and then press the Upload button.
11. When you click the upload button, the file will be added to the SharePoint Document Library folder. You can see that the flow has succeeded by looking at the Flow run history, as indicated below.
12. Go to the SharePoint Document Library (Documents) and open the existing folder (TSInfo Documents). Refresh the library; the file you need has been uploaded to the folder, as in the screenshot below. You can then open the file from the library itself.
This way, we can upload attachments to the SharePoint list using Power Apps.
From this Power Apps tutorial, I hope you learned how to upload an attachment to the SharePoint list using Power Apps.
Also, you may like some Power Apps tutorials:
- How to Make Power Apps Radio Button Field Mandatory
- Patch Power Apps Radio Button Value to SharePoint List
- Power Apps Radio Button Control
Preeti Sahu is an expert in Power Apps and has more than 6 years of experience working with SharePoint and the Power Platform. As a Power Platform expert for Power BI, Power Apps, Power Automate, Power Virtual Agents, and Power Pages, she is currently employed with TSinfo Technologies. She is the author of the book Microsoft Power Platform A Deep Dive. She also made a big technical contribution to SharePointDotNet.com in the form of articles on the Power Platform. She enjoys traveling and spending time with her family in her spare time.