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.
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
- 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.
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:
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.
- Then go to My flows -> + New flow -> Select Instant cloud flow.
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.
Step – 5:
- Next, click on the + option and add a Create file action (in SharePoint). Enter the field values as like below:
- Site Address = Select or enter the SharePoint address name where the Document library is present.
- Folder Path = Select the Document Library name and as well as the folder name where you want to upload the PowerApps attachment.
- 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.
- 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.
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.
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(
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 );
DataCardValue3_1 = PowerApps Attachment Control name
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.
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.
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.
Also, you may like these below PowerApps Tutorials:
- PowerApps Find Function
- PowerApps Trim Function
- Power BI integration with PowerApps Portals
- Power Apps Azure AD Group
- Power Apps RSS Feed
- PowerApps Weather
- PowerApps Twitter Connector
- Power Apps Calculate + 13 Examples
- Build a Calculator in Power Apps
- Power Apps Rating Control – How to use
- Power Apps Slider Control
- Power Apps Gallery Pagination
- Power Apps Data Table – Complete tutorial
- Migrate PowerApps from one tenant to another
- Power Apps Export Import Control – How to use
- Power Apps PDF Viewer – Complete tutorial
- How to use date time picker in PowerApps
This is how to upload a PowerApps attachment to a SharePoint Document Library Folder.
I am Bijay a Microsoft MVP (8 times – My MVP Profile) in SharePoint and have more than 15 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com