Add Attachments to List Item using Nintex Workflow

  • 1 October 2020
  • 1 reply
  • 771 views

Hello Everyone,

 

I'm currently struggling to add attachments to a From using Nintex Workflow.

Scenario:

There is a Nintex form with 'Attachments' field in it.

The user is given various options as in what attachment does he wants to add (using tick boxes).

(The corresponding attachments are stored in a different SharePoint list)

Based on his choice, the attachments should be added to the from.

It can be achieved using the 'Call Web Service' action, and further choosing Web Method as AddAttachment in 'On-Prem' but I'm struggling to achieve in 365.

Need help please.

 

Thanks


1 reply

Userlevel 4
Badge +10

You need to use SharePoint REST API.


https://docs.microsoft.com/fr-fr/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest#working-with-files-attached-to-list-items-by-using-rest


 


 


Take a look at this discussion: 


https://community.nintex.com/t5/Nintex-for-Office-365/Copy-task-attachments-to-Master-Item-on-O365/m-p/88410


 


In this scénario, the attachment of a task is uploaded as attachment of an item. This is similar to what you want to do (only the URL of the source document changes).


 


There are two important things


- if there has never been an attachment on the item, you need to ensure that the Attachment folder of your item exist, to do that, simply créate an empty attachment file by using 


[SiteURL]/_api/web/lists/GetByTitle('[List Title]')/items([Item ID]‌)/AttachmentFiles/add(FileName='dummy.txt')

 


 


- Upload your file as attachment of your item : 


Use the follower REST API : 


[SiteURL]/_api/web/getfilebyserverrelativeurl(@v0)/copyto(strnewurl=@v1,boverwrite=true)?@v0='‎‏[FileToUploadURL]‌'&@v1='[ListURL]‌/Attachments/‎[ItemID]/[NameOfTheFileToUpload]'

 


ps : Don't forget to remove your dummy file 😉

Reply