Photo by Anne Nygård on Unsplash

Copy task attachments to list item attachments

In this short post I will help you to build your Nintex for Office 365 workflow that will allow you to copy attachments that were added to a task to a related list item attachments. The list item is of course the one around which the whole workflow is running.

Approval task form

First you need to create an approval form.

Type of the Nintex for Office 365 form designer

It really doesn’t matter which type of a designer will you choose – each allows you to use Task attachments control (or in the modern designer – File upload control):

Attachments control in Nintex for Office 365 form designer

Configure the form the way you need it. After you’re done, get back to the approval action.

Approval action

Whether you use “Assign a task” or “Start a task process” action, you need to configure the field that returns task (or tasks) ID:

Grab generated tasks IDs in Nintex for Office 365 forms designer

You will later use those IDs to get attachments from the related tasks (or task).


Put workflow on pause so that all attachetns are uploaded

First get the workflow a moment to wait after the approval is completed. I noticed, that sometimes workflow was resuming much faster than the attachments were uploaded to the task item. In result, workflow was resumed with information about e.g. just one attachments from 3 uploaded.

Then for each generated task do the following:

For each task
  1. Prepare headers for the HTTP request:
    Request headers
  2. Perform a GET HTTP request to the following request URL:

    {SITE URL}/_api/lists/getbytitle('Workflow Tasks')/items(TASK ID FOR CURRENT LOOP RUN)/AttachmentFiles?$select=FileName,ServerRelativeUrl
    HTTP Request
  3. The response body will be of the following structure: {"value": [{"FileName": "xyz.jpg", "ServerRelativeUrl": "somepath/xyz.jpg"}]} – you need to extract the table only.
    Extract table
  4. Then perform action for each item from the extracted table.

Next for each extracted attachment (in the loop iterate over the var_Data_dict dictionary and save item as eg. var_Item_dict):

For each attachment
  1. Get filename from the dictionary
  2. Get path from the dictionary
    Get path/ filename from dictionary
  3. Prepare request headers (like above, optionally you can add second item as Content-Type: application/json)
  4. And perform the copy POST request to:
    ‍{Workflow Context:Current site URL}‍/_api/web/getfilebyserverrelativeurl(@v0)/copyto(strnewurl=@v1,boverwrite=true)?@v0='‍{Variable:var_Path_txt}‍'&@v1='/SITE RELATIVE URL TO LIST/Attachments/‍{Current Item:ID}‍/‍{Variable:var_Filename_txt}‍'
    HHTP Request "copyTo"

And that’s it! Task attachment is now added to the related list item’s attachments list. Good luck!

Tomasz Poszytek

Hi, I am Tomasz. I am expert in the field of process automation and business solutions' building using Power Platform. I am Microsoft MVP and Nintex vTE.

  • Telkom Jakarta

    It’s great to see how Nintex Workflow for Office 365 can simplify tasks and make processes more efficient. The step-by-step instructions provided in the article make it easy to follow and implement. I appreciate the effort put into explaining the concept and providing detailed screenshots for better understanding. Looking forward to more articles like this!

    May 14, 2023 at 9:53 am Reply
  • Ahmad Maza

    Hello Mr.Tomasz,
    I hope this message finds you well. I’ve been following your blog and the insights you provide on Nintex have been incredibly helpful. Currently, I’m exploring the capabilities of Power Apps and Power Automate, and I’m interested in creating a custom task form and send link via email for the custom form.

    I noticed your expertise in Nintex, but I wonder if you have insights or resources on achieving a similar functionality using Power Apps and Power Automate exclusively. If you have any articles, tutorials, or advice on this specific topic, I would greatly appreciate your guidance.

    Thank you in advance for your time and expertise!

    Best regards,

    December 3, 2023 at 2:51 am Reply
  • Gregor

    HI Thank you, i can’t figure it out. i receive always “Specified value is not supported for the serverRelativePath parameter”
    I use the relative path get by the response you mentioned. “ServerRelativeUrl”: “somepath/xyz.jpg”


    December 7, 2023 at 12:54 pm Reply
    • Tomasz Poszytek

      Be sure the path is relative down to site collection level, e.g. /sites/somepath etc…

      January 13, 2024 at 7:48 pm Reply

Post a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.