Skip to main content

The first time I worked with attachments in a workflow, I ask where are the attachments stored and how can I show all attachments in the following workflow tasks to give an approver the possibility to read the attachments.

 

I have attached an NINTEX 2013 example site workflow using NINTEX Forms 2013.

 

A prerequisite is the installation of the Get List Item Attachment in Base64 Custom Action from Vadim Tabakman‌ (see http://www.vadimtabakman.com/nintex-workflow-get-list-item-attachment-in-base64-custom-action-happy-thanksgiving.aspx).

 

In the first Flexi Task you can add multiple attachments. The task IDs are stored in the workflow variable task_ids This attachments are stored in the task items of the Flexi Task.

If the Flexi Task is approved an item is created in a data list.

 

To copy the attachments from the task item(s) to the list item the following steps have to be executed in a loop for each task ID:

  1. Call web service Lists.asmx with method GetAttachmentCollection to get the URLs of all task item attachments. The resulting XML is stored in workflow variable attachments_xml
  2. Extract the URLs from XML and store them in a workflow collection variable attachment_coll by Query XML action.
  3. For each attachment URL the following steps are executed:
    1. Get the attachment from task item in base64 format an store it in workflow variable attachment_base64
       
    2. Get the filename from attachment URL by Regular Expression action
    3. Call web service Lists.asmx with method AddAttachmentCollection to add the attachment to the list item

 

Now all task attachment are stored in the list item.

 

To show the attachments formatted  as HTML links in the next Flexi task form the following steps have to be executed:

  1. Call web service Lists.asmx with method GetAttachmentCollection to get the URLs of all list item attachments. The resulting XML is stored in workflow variable attachments_xml
  2. Extract the URLs from XML and store them in a workflow collection variable attachment_coll by Query XML action.
  3. For each attachment URL the following steps are executed:
    1. Get the filename from attachment URL by Regular Expression action
    2. Build the html coding for the links and store it in the workflow variable attachment_html_links

Now the html coding for the attachment links is ready to be rendered in the form of the next flexi task.

 

To show the links in the form I used a Rich Text control. My first attempt to enter the worklfow variable by Insert Referenz to the control was unsuccesful - the html coding was shown, not the rendered link. So a little JavaScript was neccessary. First I assigned a unique CCS Class name Anlagen to the control. Second I created a Single Line Textbox control where I inserted by Insert Referenz my workflow variable containing the html coding. The control itself was made invisible on the form by css. By JQuery the html content of the control will be replaced by the content of my workflow variable:

NWF$(document).ready(function () {

    try {

          NWF$('.Anlagen').html(NWF$('#'+ anlagen_html).val());

    } catch (err) {

 

    }});

Now the attachment links will be rendered:

I hope it is helpful for someone!

 

Manfred

Great, that's a very nice feature.
I've created this once and it still works really fine. But I would like to use such UDA in the same site collection twice, so I had to create it once more. But this UDA always gets an error.

"Failed to invoke web service. Error returned from server. The remote server returned an error (401) Unauthorized"

I did it in the same way .... any ideas?


So Helpful!  Thanks very much.

I installed Vadim Workflow and was able to use pieces of your workflow.

It kept looking for your web credentials--I had to find every place and substitute mine.

Saved me a lot of work to get testing.


Will you please explain in more details or attach screen shots for the para taken from above blog.  I have successfully created workflow variable having html coding and able to open through my mail, but can not attach to any control in Task Form attached to Flexi Task.  Will you please explain which control to use, where to add CSS class etc :

Now the html coding for the attachment links is ready to be rendered in the form of the next flexi task.

To show the links in the form I used a Rich Text control. My first attempt to enter the worklfow variable by Insert Referenz to the control was unsuccesful - the html coding was shown, not the rendered link. So a little JavaScript was neccessary. First I assigned a unique CCS Class nameAnlagen to the control. Second I created a Single Line Textbox control where I inserted by Insert Referenz my workflow variable containing the html coding. The control itself was made invisible on the form by css. By JQuery the html content of the control will be replaced by the content of my workflow variable:

NWF$(document).ready(function () {

    try {

          NWF$('.Anlagen').html(NWF$('#'+ anlagen_html).val());

    } catch (err) {

    }});


I am sorry for my ignorance, but I am fairly new to Nintex and cannot figure out how to install this solution.  I need to save attachments to Items in my list.  I was directed to Vadim Tabakman's solution and am trying to figure out how to install the Get List Item Attachment in Base64 (see http://www.vadimtabakman.com/nintex-workflow-get-list-item-attachment-in-base64-custom-action-happy-thanksgiving.aspx).

The directions indicate:

To install this solution, run the following command line :
stsadm -o addsolution -filename VTListItemGetAttachmentAction.wsp

But where do I run this code?  I tried to use the Run command from the Windows Start menu, but I get the error message "Windows cannot find stsadm"  Where is this file?  I am using SharePoint installed on company servers, so perhaps the SharePoint admin team needs to run it?

Thoughts?


you should hand over it to your SP admin, it has to be run on server.


what if you have office 365?


Is this still working? It is not logging history as well as it is not creating list item attachment? I have uploaded Vadims solution.


Hi there,

I am using Flexi Task in my workflow and copying attachments from Flexi Tasks to List Item. It was working fine till week back and suddenly it has started throwing error " Failed to invoke web service. Error returned from server: The remote server returned an error: (400) Bad Request." in AddAttachment service call. Whereas GetAttachmentsCollection service call is working fine.

Kindly help me with this.


Hi Satish,

The error may be due to password change or expiry.  You may recollect that for web service setup user id and password need to be given.

Alternatively you may create Workflow Constant on the site and use it in Web Service.  Screen shot to create Workflow constant.

 

Sunil 


Hi Sunil,

Thanks for your reply.

Password is not the issue. I am using same credentials for GetAttachmentsCollection service call which is working for me. Something's wrong with AddAttachment service Call.

-Satish


Hi mlauer, I've been working on the setup for this.  However, I am unable to get Vadim's UDA.  Also, is this set up to work in SP 2016 on prem?  I'm concerned that it might not work in my environment.  



Ultimately, I do need to get list item attachments to display during use of a workflow with FlexiTask (and a modified Nintex Form for the task).  Thank you for any guidance.  Carolyn


Reply