Add Attachment

Definition

The "Add Attachment" action allows a user to attach a file to a specific item within a SharePoint List. This action programmatically uploads a file and associates it with a designated list item, streamlining processes that require document handling directly within SharePoint.

Key capabilities include:

  • Targeting a specific item by providing the Site ID, List ID, and Item ID.
  • Uploading file content and optionally setting a custom file name.

This action is valuable for automating workflows where documents, images, or other files need to be dynamically linked to SharePoint list records, such as archiving form submissions or saving generated reports.


Inputs

  1. Connection This field establishes the authenticated connection to your SharePoint environment, authorizing the action to access and modify your SharePoint lists.
  2. Site Id The Site ID is a unique identifier for a SharePoint site (or a Microsoft 365 Group site) within your organization's SharePoint environment. Every SharePoint site, including team sites, communication sites, and OneDrive for Business sites, has a unique Site ID that must be specified to locate the correct list.
  3. List Id This is the unique identifier for the SharePoint list where the target item resides. Since each site can contain multiple lists, you must either enter a specific List ID or select one from the drop-down menu that appears after a connection is established.
  4. Item Id The Item ID is the unique identifier for the specific item within the SharePoint list to which you want to add the attachment. Each item in a list is assigned a distinct ID by SharePoint, which is required to link the attachment to the correct record.
  5. File Content This field holds the content of the file that you want to attach to the item. You can provide the file content dynamically, for example, from a previous action that generated a document or retrieved a file from another system. The maximum file size for an attachment is 15 MB.
  6. File Name This is an optional field where you can enter a new name for the file without including the file extension. If this field is left blank, the attachment will retain its original file name.

Outputs

  1. Site Id The unique ID of the SharePoint site where the attachment was added.
  2. List Id The unique ID of the SharePoint list containing the item that now has the new attachment.
  3. Item Id The unique ID of the item to which the file was successfully attached.
  4. File Name The display name of the file that was attached to the list item.
  5. Relative URL The server-relative path of the attached file within the SharePoint site. This URL is relative to the site's domain.
  6. Absolute URI The full, direct URL (Uniform Resource Identifier) of the attached file. This link can be used to access the file directly via a web browser or another application.

Example Use Cases

  1. Automate Invoice Archiving Automatically attach incoming vendor invoices from an email or form to the corresponding purchase order item in a SharePoint list.
  2. Store Onboarding Documents Attach a new hire's signed offer letter or policy agreements to their specific record in an employee onboarding SharePoint list.
  3. Log Project Deliverables Add project-related files, such as design mockups or status reports, as attachments to the relevant task or milestone item in a project tracking list.
  4. Archive Form Submissions When a user submits a form, generate a PDF summary of their response and attach it to the new list item created for that submission.
  5. Manage Support Tickets Attach screenshots, log files, or other relevant documents provided by a customer to the corresponding support ticket item in a SharePoint list.

Example

Scenario: The finance department uses a SharePoint list called "Purchase Orders" to track all company expenditures. When a vendor submits an invoice as a PDF to a designated email address, the accounts payable team needs to manually download the invoice and attach it to the correct purchase order item in the list. This process is time-consuming and prone to human error.

Steps to Implement:

  1. Set the Trigger: Start the zenphi Flow with a trigger, such as "New Email" from the Gmail, configured to monitor the dedicated invoices inbox.
  2. Identify the List Item: Use a "List Items" action from the SharePoint List connector to search the "Purchase Orders" list. Filter the items using the purchase order number found in the email subject or body to locate the correct list item and retrieve its Item Id.
  3. Configure the "Add Attachment" Action: Drag and drop the "Add Attachment" action into the Flow.
  • Connection: Select your pre-configured SharePoint connection.
  • Site Id: Choose the Finance department's SharePoint site from the dropdown menu.
  • List Id: Select the "Purchase Orders" list.
  • Item Id: Use the token picker to insert the Item Id from the output of the "Get Items" action in the previous step.
  • File Content: Use the token picker to select the file content of the email attachment from the trigger.
  • File Name: Optionally, use the token picker to set a standardized name, such as combining the original file name with the purchase order number (e.g., "PO12345-Invoice.pdf").

Outcome: This automation completely eliminates the manual work of saving and uploading invoices. Every time a vendor emails an invoice, the Flow automatically identifies the correct purchase order in SharePoint and attaches the document. This ensures that all financial records are accurately updated in real-time, reduces the risk of misfiling documents, and frees up the accounts payable team to focus on more critical tasks.


Best Practices

  1. Standardize File Naming Utilize the File Name input field to create a consistent naming convention for your attachments (e.g., "Invoice-[ItemID]-[Date]"). This makes files easier to identify and manage directly within the SharePoint list item.
  2. Verify Item Existence First Before using the "Add Attachment" action, incorporate a "Get Items" action with a filter to ensure the target Item Id exists. This prevents the Flow from failing if the item has been deleted or was never created.
  3. Manage File Size Limits Be aware of the 15 MB file size limit for attachments. For larger files, a better practice is to upload the file to a SharePoint Document Library and then store the link to the file in a field on the list item instead.
  4. Use Dynamic IDs Avoid hardcoding the Site Id, List Id, or Item Id. Whenever possible, populate these fields using tokens from previous actions in your Flow. This makes your workflow more robust, reusable, and easier to maintain if site or list structures change.