cancel
Showing results for 
Search instead for 
Did you mean: 

Improve Task Forms with List Item Attachments

Workflow Hero
18 12 3,887

List item attachments are not available from a task form – even one customized with Nintex Forms. Providing all pertinent information (including related documents) to complete an approval task from a single form, can go a long way toward making the user experience as seamless as possible for approvers.

This post 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? The following solution produces a similar outcome, without the need for any custom actions.

The Workflow

Get Attachments

First, use the Call web service action to get all attachments from the current item and store the URLs to a multi line of text variable.

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

Query XML

Start an HTML Table

The collection of URLs needs to be formatted in a user friendly way for the task form. So, use a Build string action to start an HTML table. Store the beginning of the HTML table to a multi line of text variable. The rest of the table will be dynamically built out based on the attachments collected.

Build String - Start HTML Table

Loop Through the Collection of URLs

Use a For each action to loop through each URL in the collection and dynamically build out the rows in the HTML table.

For Each

Get Each Document Name

Use a Regular expression action to get the clean file name from each URL and store to a single line of text variable. This will be used 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.

Regular Expression - Get Clean Doc Name

Add a Row to the Table

The last step within the For each action, is to add a row to the HTML table using another Build string  action.

Build String - Add Row

Close the HTML Table

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

Build String - Close Table

Populate List Column

Create a new multi line of text column on the list and use the Update item action to populate that column with the value that was collected during the workflow.

Update Item - Attachments HTML

Task Form Configuration

Within the task action configuration in Nintex Workflow, open the Nintex Forms designer and 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

Task Form - Attachments HTML

The Final Task Form

Flexi Task Form with Attachments

Check out the full solution details here: https://nicoleprestby.wordpress.com/2017/12/19/add-list-item-attachments-to-task-form-using-nintex-w...

12 Comments
Workflow Hero

This is so awesome Nicole!!

Thanks for sharing out this great solution.

Vadim

Workflow Hero

Thanks for the Solution. Happy New Year in advance

Workflow Hero

Ironically, I did this the other week before reading this blog. Great Minds

Workflow Hero

Thanks for sharing this solution Nicole, I've been looking for one that will nicely work with multiple attachments.

I've tried few others but not working as I expected. I'll definitely give it a shout.. Thanks again  

Workflow Hero

An Update: I applied the solution and it works like a charm.. Million Thanks Nicole  

Workflow Hero

Great - glad to hear it worked for you!!

Workflow Hero

Extremely helpful Nicole! Thanks for sharing

Workflow Hero

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.

Workflow Hero

Hi Mark Roadley - 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.WFCons....


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.

Workflow Hero

Nicole - thank you for your prompt response.

As to your 1st question.

  • I created a Multi-Line Text column on the list.  This is the screen shot of the value in the list table view, after running your WF.

  • When modifying the Task Form, I added the new MLT column (control) to the form in 2 different ways:
    1. Simply chose the column from the list columns - for the setting Connected to I connected the defined list column
    2. Dropped in an unconnected MLT Box - for the setting Connected to I left it as "Not Connected", then for Default Value I grabbed the Column name from the Insert Reference.
    3. This is the screen shot of the value as it appears in the Task Form - rendered the same in both of the above form controls

Clearly, I have missed something.

I went back and double/triple checked all the action steps in the WF.0

Other ideas on what to check for?

As to your response #2, I am a SP Site Owner/Administrator - however, I do not have access to Central Administration or any of the familiar SP development tools such as SPD.  All my work has to be accomplished using the tools contained within the purview of a typical site owner.

Having said that:

  1. You were correct in presuming I cannot create an Administrative Account with a non-expiring PW.  I will look into that possibility with our IT Security team, but not hopeful. Our credentials are managed through an AD.
  2. Aside from the maintenance task of having to update the credential's Password on a regular basis (as mandated by Corp Security) the 2 scenarios I am envisioning are inevitable:
    1. I forget to update the WF when my own corp credentials need to be updated
    2. I have moved on to other roles or left the firm, and am not available to update the credential, or my credentials have been deleted. 
  3. In my mind, ideally, the WF should be able to use the credentials of the user who initiated the approval task.

Is there a solution taking into account my use case scenarios?

Thank you

Mark

Workflow Hero

This is a great alternative to other solutions to this problem I have seen but it also has some of the same drawbacks. What if the task is not expected to be completed in a short time frame and additional attachments are added after the task is created? I recently came up with the following solution to this and I'd love to get some feedback to see what problems it might have. I simply added a calculated field to the task form and gave it a CSS class of attachmentField. I then added the following to the custom JavaScript of the form.

NWF$(document).ready(function(){
    // Rest URL
    var requestUri = "Site URL/_api/lists/getbytitle('Project Planning Worksheet')/items(ID)?$expand=AttachmentFiles";
    var attachmentsHTML = '<div>';       
    $.ajax({
            url: requestUri,
            type: "GET",
            headers: { "ACCEPT": "application/json;odata=verbose" },
            success: function (data) {               
              $.each(data.d.AttachmentFiles.results, function (i, item){
                 var x = item;
                 var attachmentUrl = item.ServerRelativeUrl;
                 var fileName = item.FileName;
                 attachmentsHTML += '<a href="' + attachmentUrl + '" target="_blank" >' + fileName + '</a>' + '<faketag>';
                 attachmentsHTML = attachmentsHTML.replace("faketag","br /");
                });
             attachmentsHTML += '</div>';
             NWF$(".attachmentField").html(attachmentsHTML);
            },
            error: function () {
                alert("Error getting the Item Attachments");
            }                    
        });

});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

In the requestUrl the Site URL and ID are references. You may notice a weird "<faketag>" that was my workaround to Nintex replacing my <br /> tag with an end of line even though it was in quotes in a string. Obviously this is just some very simple formatting to add the links to the attachments to the task form and it could be expanded upon.

Thanks,

Brian

Workflow Hero

When I add to my Nintex Form an html link tag (<a>) from Nintex Workflow proccess in a control Enhanced Rich Text (in Nintex form) my link appears on the form without http.

For example: I try to add a control <a href="google.com">google</a> in Nintex workflow, but when this control is added to Enhanced Rich Text  it appears as <a>google</a> 

Does anybody have an idea why this is happening?