Save Power Apps Form Attachments to SharePoint List Using Power Automate

A few days ago, I received a client requirement to save Power Apps form attachments to a SharePoint list. The client was submitting form input data from Power Apps to a SharePoint list using a Power Automate flow. However, they faced an issue when trying to submit multiple attachments to a single list item.

In this tutorial, I will explain how to save Power Apps form attachments to a SharePoint list using a Power Automate flow.

Save Power Apps Form Data (with attachments) to SharePoint List Using Power Automate

When saving multiple attachments from a Power Apps form to a SharePoint list using Power Automate, many users encounter issues. This happens because Power Apps sends the attachments in a table format, which Power Automate does not directly support.

Even if we convert the table data to JSON and parse it, Power Automate cannot correctly read the file content to save it as attachments. To solve this problem, we used a simple two-flow approach:

  • Flow 1 = Save the Power Apps form data into the SharePoint list. While saving, we also retrieve the item ID of the newly created list item.
  • Flow 2 = Use the retrieved Item ID to upload all the attachments from the form and link them to that specific list item.

With this, we can save multiple attachments from a Power Apps form into a single SharePoint list item without errors.

Let’s start implementing this step by step:

  1. Here is the SharePoint list that stores multiple attachments from the Power Apps form using a Power Automate flow.
Save Power Apps Form Data to SharePoint List Using Power Automate

This list contains the following columns with the given data types:

Column NameData Type
TitleDefault
Employee NamePerson Field
DepartmentChocie
Expense dateDate and Time
Expense AmountNumber
Expense CategoryChoice
AttachmentsDefault field
  1. Now, in Power Apps, add an Edit Form control and set the SharePoint list name as the data source for this form, as in the image below.
Save or Update Custom form data to SharePoint List from canvas App using flow
  1. Now, create an Instant Cloud Flow in Power Automate and then add the ‘When Power Apps calls a flow (V2)’ trigger as shown in the image below.
    For that trigger, add the inputs to retrieve Power Apps form input data. Take reference from the table below.
Input NameData Type
ExpenseTitleText
EmployeeEmailEmail
DepartmentText
ExpenseDateDate
ExpenseCategoryText
ExpenseAmountNumber
Save Form's Data & Files to SharePoint after Approval using Power Automate
  1. Then, add a Create item action to save the form input data to a SharePoint list. In the Parameters section, you can see that I am passing the following details:
    • Site Address = Provide SharePoint site address.
    • List Name = Provide SharePoint list name. Then, open the advanced parameters, and it will display the columns of the SharePoint list as shown in the image below.
    • Now, assign the trigger inputs to those columns:
    • Title = ExpenseTitle
    • Employee Name Claims = EmployeeEmail
    • Department Value = Department
    • Expense Date = ExpenseDate
    • Expense Amount = ExpenseAmount
power automate flow to save power apps form in sharepoint
  1. The above action will create an item in a SharePoint list with a Power Apps form input. Now, we need that item ID so we can update the attachments to the list item. To retrieve the ID and return it to Power Apps, need to add ‘Respond to Power Apps or flow action.
  2. Add a Number input in that action and assign the ID from the Create item action.
Microsoft Forms Power Automate get response details
  1. Now, save the flow and publish it. Next, we will create another simple flow that adds an attachment to the SharePoint list item.

Here, also create an Instant Cloud Flow, and then select ‘When Power Apps calls a flow (V2)‘. As in the image below, and in this trigger, add two inputs such as:

  • ItemID =Number
  • File content = File
Power Automate Get response details Response ID
  1. Then, add the ‘Add attachment‘ action, and then provide the inputs to the parameters.
    • Site Address = Select SharePoint site address.
    • List Name = Select the SharePoint list name
    • Id = Assign the trigger item ID.
    • File Name = triggerBody()?[‘file’]?[‘name’]
    • File Content = triggerBody()[‘file’][‘contentBytes’]
save power apps form attachments to sharepoint list using flow
  1. That’s it, save the changes and publish them. Then in Power Apps, click on the … More options on the left side-> Select Power Automate -> Add flow ->Select the flows. Then it will add those flows into the Power Apps application.
store power apps form attachments to sharepoint list using power automate flow
  1. Now, we need to pass inputs to the Power Automate flow from the Power Apps. Now, provide the code below in the Submit button of Power Apps.
Set(varItemID,
AddAttachmentWithData.Run(
    DataCardValue1.Text,
    DataCardValue2.Selected.Email,
    DataCardValue3.Selected.Value,
    Text(DataCardValue4.SelectedDate, "yyyy-mm-dd"),
    DataCardValue6.Selected.Value,Value( DataCardValue5.Text)   
    
));
ForAll(
    DataCardValue8.Attachments As Document,
    ExpenseAttachmentsSaving.Run(
        varItemID.id,
        {
            name: Document.Name,
            contentBytes: Document.Value
        }
    )
);

Here:

  • AddAttachmentWithData.Run() = We are passing form input data to the Power Automate flow. Then, store the output in the varItemID variable.
  • ExpenseAttachmentsSaving.Run() = For this flow, we are passing varItemID. Then, passing the attachment flow name and its content bytes.
  • ForAll() = Using this function, we iterate over each attachment and send that to the Power Automate flow as an input, so the flow will take that attachment and submit it to the SharePoint list.
power automate flow to save the power apps form attachment

Now, save the changes and publish them. Then, test it, providing the form input data with attachments. Check the SharePoint list; you can see the list item data is saved successfully, along with attachments, as in the example below.

power automate flow to store multiple power apps form attachments

This way, we can save multiple Power Apps form attachments to a SharePoint list item using a Power Automate flow.

I hope you found this article helpful! In this article, I provide a solution for submitting multiple attachments to a SharePoint list item. Follow this article if you are also trying to submit multiple attachments from a Power Apps form to a SharePoint list using a Power Automate flow.

You may also like:

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial

FREE Power Platform Tutorial PDF

Download 135+ Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…