Your Microsoft Technology Development and Consulting Experts - Operating since 2000
If you've ever tried to implement file attachments in Power Apps, you know it can be surprisingly challenging. You would expect attaching files to be a straightforward process, but the traditional approaches often involve complex workarounds and multiple steps for users.
The good news? Microsoft has significantly improved this process with a new action in Power Automate that makes uploading documents to SharePoint document libraries much simpler and more efficient. In this guide, I'll show you:
Head over to my YouTube channel Chino Does Stuff to watch the video tutorial, there you will see a variety of videos with loads of tricks and tips on the entire Power Platform suite.
Before diving into the implementation, let's understand why this method is superior to older approaches:
One quirk of Power Apps is that the file attachment control isn't directly available in the insert menu. Here's how to add it to your app:
After pasting, you'll need to fix some errors in the control:
The MaxAttachments and MaxAttachmentSize properties are particularly important to configure based on your requirements.
Next, we'll create a flow that receives files from Power Apps and saves them to a SharePoint document library:
In SharePoint, create a document library to store your attachments. Add a Number column called "ParentId" - this will store the ID of the related record from your list.
In Power Automate, create a new automated flow with these steps:
Save your flow with a descriptive name like "Save File to SharePoint".
Now, we need to modify our app's save button to handle both the record creation and file uploads:
Let's break down what's happening here:
When a user fills out your form and attaches files:
This entire process happens seamlessly, and the user only needs to click Save once.
To display files associated with a record, you'll need to:
The formula for the gallery's Items property would be something like:
Filter(YourDocumentLibrary, ParentId = CurrentRecord.ID)
When implementing file attachments in Power Apps:
This approach can be extended in several ways:
With Microsoft's improved Power Apps V2 trigger in Power Automate, handling file attachments in Power Apps has become significantly easier. This approach provides a clean, user-friendly way to upload files to SharePoint and maintain their relationship with your app's data.
By using a document library instead of list attachments, you gain all the benefits of SharePoint's document management capabilities while providing a seamless experience for your users.
This method eliminates much of the complexity that was previously required for file uploads in Power Apps, making your apps more maintainable and user-friendly.
If you'd like to see more Power Apps development tips and techniques, please head over to the YouTube channel and leave a comment there. I actively monitor and respond to all YouTube comments!
Marcello is a lead developer at Powerplatform Experts, an expert in, Computer Science, Power Platform integration and founder of the YouTube channel ChinoDoesStuff. If you have any questions, please feel free to get in contact at via the form below.
Copyright © 2024. Brayalei Pty Ltd T/As Office Experts Group. ABN 32 093 067 737. ACN 093 067 737. All Rights Reserved.