2 Ways to Add Attachments to a SharePoint List Item in Power Automate

Do you need to add attachments to a SharePoint list item from your flow?

One of the key features of SharePoint is its ability to create and manage lists of information, such as tasks, contacts, and issues.

When it comes to efficiently organizing data, SharePoint lists are a practical solution. List items can contain information such as text, dates, and even hyperlinks. Plus, users have the ability to add attachments to each item in the list, ensuring that relevant documents and files are always easily accessible.

Power Automate has a robust connector in Power Automate with many useful actions. These actions will allow you to automate the addition of relevant files to your SharePoint list items.

This article will guide you on how to effectively utilize Power Automate to attach documents and maintain organization in your SharePoint lists.

Show the Attachment Field in Your List

The system generated SharePoint attachment field is a feature that allows users to attach files to a list item in SharePoint.

Every list you create will contain this field, but by default, it will be hidden from view.

You don’t need to add this field to your view in order to add attachments, this is an optional step to help make any attachments more visible to users of your list.

To display the attachment field in your SharePoint list, you need to customize the list view.

  1. Navigate to your SharePoint list and click on the View settings on the toolbar. This might be labeled as All Items which is the default view name.
  2. Select the Edit current view option in the dropdown menu.

Once you’re in the Edit View settings menu, add the column titled Attachments.

  1. Check the Attachments column.
  2. Press the Ok button to save the updated view.

This will enable the attachment column in your list view, allowing you to see which items have attachments.

The attachment column only displays an attachment (paperclip) icon and does not show the specific attachments.

You can click on the Title for any list item with attachments to view the list of attachments for that item. This opens the list item on the right side of the window and you can see the attachments.

💡 Tip: Double left-click anywhere on the list item to open the list item right window pane.

You can then click on any of the attachments to open them.

Add a Single Attachment from SharePoint

In this section, you will learn how to add a single attachment stored in a SharePoint library to your SharePoint list item.

The process involves three main steps.

  • Retrieving file metadata using the Get file metadata using path action.
  • Obtaining the file content with the Get file content action.
  • Adding the attachment using the Add attachment action.

Get File Metadata using Path Action

You need to obtain the file metadata using the Get file metadata using path action.

This is needed to get the file’s unique identifier as well as the file name and extension type.

The unique identifier will be used to get the file contents and the name and extension are needed to name the attachment in your list. Without the correct extension, you won’t be able to open the file from your list.

  1. Add the Get file metadata using path action to your flow.
  2. Provide the Site Address where the file you want to attach is located.
  3. Select the File Path using the file picker menu from the Folder icon. You can also use dynamic content or an expression for the file path and file name in this field.

This will get you the relevant metadata for the file that will be used in later actions.

Get File Content Action

Next, you’ll need to obtain the file content with the Get file content action.

  1. Add the Get file content action to your flow.
  2. Select the Site Address of the SharePoint site where the file you want to attach is stored.
  3. Add the Id dynamic content from the Get file metadata using path action to the File Identifier field.

This action will provide you with the actual content of the file you want to attach.

Add Attachment Action

Finally, you can now add the attachment to the SharePoint list item.

Here’s how to add the attachment.

  • Add the Add attachment action to your flow.
  • Select the Site Address of the list where you want to add an attachment. This can be a different site from where the previous actions were to get the file content.
  • Select the List Name from the dropdown list.
  • Set the Id of the list item to which you want to attach files. This can be a value, dynamic content, or expression that returns an integer value.
  • Add the Name dynamic content from the Get file metadata using path action. This includes the file name and file extension such as .pdf, .jpg etc. The extension is essential if you want to be able to open the files properly.
  • Add the File Content dynamic content from the Get file content action to the File Content field. This is the actual content of the file.

This will successfully add your selected single attachment to a SharePoint list item.

Add Multiple Attachments from SharePoint

This section will show you how to add multiple attachments from a SharePoint folder to your SharePoint list item.

The process involves four main steps.

  • Retrieving file metadata for each file in the folder using the Get files (properties only) action.
  • Adding an Apply to each action to loop through each file.
  • Obtaining the file content for each file with the Get file content action.
  • Adding each file attachment using the Add attachment action.

Get files (properties only) action

This is the major difference between the two methods.

The Get files (properties only) action can be used to get the metadata for all the files in a given folder. Then you will be able to loop through the results to add the files as attachments to your list item.

  1. Add the Get files (properties only) action to your flow. This action fetches the basic properties of the files stored in your SharePoint document library.
  2. Select the Site Address where the folder of files you want to attach.
  3. Select the Library Name that contains your folder of files.
  4. Select the folder with the Limit Entries of Folder field. Click on the folder icon to use the folder picker menu to select the folder.
  5. Choose either Yes or No for the Include Nested Items option. If you select Yes, this will return all files in all subfolders of the main folder, otherwise selecting No will return only the files in the main folder.

This returns an array will all the file metadata, and this can be looped through using an Apply to each action.

Apply to each action

Next, you can add the Apply to each action in your flow. This action loops through each file fetched by the Get files (properties only) action.

  1. Add an Apply to each action to your flow.
  2. Add the value dynamic content from the Get files (properties only) action. This is the array of file metadata from your folder.

Get file content action

Now you can add the Get file content action within the Apply to each loop.

This action retrieves the actual content of the files based on a file identifier from the Get files (properties only) action.

  1. Add the Get file content action within the Apply to each action of your flow.
  2. Select the Site Address of the files you are going to attach.
  3. Add the Identifier dynamic content from the Get files (properties only) action to the File Identifier field.

Add attachment action

Finally, you can use the Add attachment action inside the Apply to each loop to attach the files to your SharePoint list items.

  1. Add the Add attachment action to your flow inside the Apply to each action.
  2. Select the Site Address of the list where you want to add an attachment.
  3. Select the List Name from the dropdown list.
  4. Set the Id of the list item to which you want to attach files. This can be a value, dynamic content, or expression that returns an integer value.
  5. Add the File name with extension dynamic content from the Get files (properties only) action. This includes the file name and file extension which is essential if you want to be able to open the files properly.
  6. Add the File Content dynamic content from the Get file content action to the File Content field. This is the actual content of the file.

This will successfully add multiple attachments from SharePoint to a list item.

Conclusions

Adding attachments to a SharePoint list item is possible in Power Automate.

You need to utilize actions such as Get file metadata using path or Get files (properties only) action to first get the file metadata.

Then you can use the Get file content action to get the actual file contents.

Finally, the Add attachment action will allow you to add the files to your list items.

Do you use the attachment feature in your SharePoint lists? Let me know in the comments.

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Related Articles

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!