Add List Item Attachments to Task Form using Nintex Workflow and Forms

I had a requirement from a client recently to show all list item attachments on the various task forms in an approval process – which, if you think about it, makes total sense. With any project, we always have a common goal of making the user experience as seamless as possible for our users and approvers. So, why wouldn’t we provide all pertinent information needed (including related documents) to complete the requested review and approval, right there on the task form?

I found a post on Nintex Connect which walks through meeting this requirement by leveraging a custom action created by Nintex Technical Evangelist, Vadim Tabakman. But, what if you don’t have access to deploy a custom action to your SharePoint environment? In this case, I actually didn’t have access to the client’s server. So, I decided to come up with a solution that would produce a similar outcome, without the need for any custom actions.

The Workflow

Get Attachments

First we need to get all of the attachments from the current item and store the URLs to a collection variable. We do this with the Call web service  action, where we leverage the SharePoint Lists web service and the GetAttachmentCollection web method. We set the listName parameter to use the current List Name, found in the Common section of the dynamic references, and the listItemID parameter to use the current item ID. Lastly, we provide a multi line of text variable to store the XML result.

callwebservice_getattachmentcollection

Next, use the Query XML  action to parse through the web service result and get a collection of attachment URLs.queryxml

Start an HTML Table

Now that we have a collection of URLs, we need to format this in a way that will be user friendly on the task form. So, we will dynamically generate an HTML table, based on how many attachments were collected. We use a Build string  action to start our table and store to a new multi line of text variable. We will use this same variable as we add each component to our HTML table.

buildstring_starttable

Loop Through the Collection of URLs

We use a For each  action to loop through each URL in our collection and dynamically build out the rows in our table.

ForEach.jpg

Side note: Within the For each, I like to use the Log in history list action to write out the current URL each time we loop through the collection items. This is helpful to track the progress of your workflow and to see where we are in the looping process.

Get Each Document Name

I wanted to replicate the way that attachments are displayed on a list item form by default, where the document name is the clickable text that you see. After investigating the format of all of the URLs, I determined that each one had a common pattern just before the file name – /attachments/123 (where 123 represents the current item ID). So, we use the Regular expression  action to target on that pattern, strip everything before the file name, and store the clean name to a single line of text variable.

RegEx_GetCleanDocName.jpg

Add a Row to the Table

Once we have the URL and the document name, the last step within the For each  action, is to add a row to our HTML table using another Build string  action. We start by inserting a reference to the multi line of text variable in which we stored the start of our HTML table. Then, add some additional HTML for a single row with a hyperlink, and store back to the same variable.

BuildString_AddARow.jpg

Close the HTML Table

Just outside of the For each  action, we use one more Build string  action to close out our HTML table and we are ready to go.

BuildString_CloseTable.jpg

Populate List Column

Once we have collected and formatted all of the data the way we want it, we are almost ready to add it to our task form. I found that if we add the variable directly to the task form, it comes through as literal HTML instead of the formatted list of hyperlinks that we want. So, we need use a list column instead. Which means, the last step before adding our HTML to the task form is to create a new multi line of text column on our list and use the Update item  action to populate that column with the value that was collected during our workflow.

updateitem_attachmentshtml

Task Form Configuration

Now, we are ready to add the attachments onto the task form. Within the task action configuration in Nintex Workflow, open the Nintex Forms designer by selecting “Edit Task Form” from the ribbon. From the Nintex Forms designer, add the Attachments HTML list column onto the form and then update the following two configuration settings:

  • Expand the Appearance  section and set Enabled  = No
  • Expand the Advanced  section to set the Control Mode  = Display

taskform_attachmentshtmlconfigsettings

The Final Task Form

And that’s it, friends! We now have a Nintex task form which also displays the related documents for the corresponding list item on which we are approving.

flexitaskformwithattachments

3 thoughts on “Add List Item Attachments to Task Form using Nintex Workflow and Forms

  1. Nicole – I also provided the below as a comment to your blog posting on the Nintex Community site:
    Of course, on your page here, the screen shot images I provided do not copy/paste.

    Nintex WF 2013
    sharePoint 2013
    Windows 7, IE 11

    Nicole – thank you for the great step-by-step detail. I’m getting a partial result as seen below – perhaps you could identify where my misstep is – also a couple of questions if I may:

    1) This is the result I get after running the WF – Clearly I’m missing something when I get to one of the later action steps in the Loop

    2) in the detail for Calling the Web Service, this is what I have, which seems to be working.

    My question is, are there values that I can use other than my own Username and Password, as our passwords are changed frequently – perhaps I’m not reading your guidance correctly?

    3) In your detail for the step for getting a sltCleanDocName, are the punctuations commas or periods? This is what I understood you to mean, using periods: .+[/Attachments/].+[/]

    4) This is what I have for the last step in the Loop, adding rows to the table

    5) Lastly, I chose to run the workflow as a Start WF action step at the start of the Request Approval WF. Is there a best practice where this WF should be initiated? I assumed as long as it was run before the Request Approval WF was acceptable.

    Any assist you could provide would be appreciated.

    Like

    1. Hi Mark – Happy to help!

      1. Is this the screenshot of the data when placed on your task form? Are you writing the Multi Line Text variable to a Mutli Line Text list column? This has to happen in order for the data to display correctly. If you try to put the variable directly on the form you may end up with unexpected results.

      2. Yes, you can use a Workflow Constant as an alternative for hard-coding your personal credentials into the WF. We typically recommend that our clients create an account to be used for admin activities with a password that never expires. Even if you aren’t able to get access to an account which doesn’t expire, putting your credentials into a WF Constant is a better practice becasue when your password changes, you only need to update it in one place (the WF Constant) and all actions in all WFs that are leveraging that WF Constant will get the latest password. Here is more information re: WF Constants: https://help.nintex.com/en-US/nintex2013/help/#Workflow/RootCategory/Designer/Nintex.Workflow.WFConstants.htm.

      3. Yes, you are correct. Periods, not commas.

      4. Looks good to me.

      5. Yes, as long as you run these actions before the task is assigned, it should work.

      Let me know if this gets you anywhere.

      Like

      1. Thank you Nicole for your reply.

        I’ve left a detailed response with answers to both 1 and 2/

        Regards

        Mark

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s