rasmusn

Attachment links in 'Send e-mail'

Discussion created by rasmusn on Jul 30, 2015
Latest reply on Mar 2, 2017 by courtney.shelton

Hello!

 

This post is to share the solution i cooked together from Nintex guide, user-made guide and some of my own additions.

 

The orginal goal was to send attached files in email through a Nintex workflow, but that does not seem possible at the moment, not easily at least?, but the goal changed.

 

Goal: To send links of the attachments though the workflow 'Send e-mail'.

Result: The ability to put direct links to the attached files direct from the sharepoint list in 'Send e-mail'

What it does: The workflow will loop through the attachments and store the filenames for each file in a collection. Then it counts the amount of items in the collection and grab each input and put it in a variable. The latter part is handled in a bunch of Run if's and therefor in my case I allowed 3 max attachments. If no attachments the workflow will continue as you build it for, and the filename variables will be empty in the mail.

Disclaimer: This might not be the smartest solution, and i've yet to look at the optimizing to see if i can cut out steps in the workflow. But it works, which is a good thing ;-) My Nintex is default to Danish, so i might name some of the operations a bit wrong in english.

 

How to

Step 1

Setup the Web service call and get filename loop. This part is based on Alan Richards' Nintex attachment workflow with some minor changes. Follow that guide with these changes:

What to skip: Office 365 Upload file

What to add: In between the second 'Do Calculation' and 'Set Workflow Variable' add a 'Add Item to Collection' with the following values:

 

1.PNG

The collection can be named what ever you want, i made it from the from the settings on the go.

 

Step 2

Count the collection and build variables (outside the loop from step 1)

1. Add a 'Count Items in Collection' with the following settings: Target collection: target_collection, total items: items_in_collection  (new variabel: integer)

2. Add 'Run if' with the following settings: Expression when 'workflow variables' items_in_collection equals value 1

2.1 Inside the 'Run if' add a 'Get Item from Collection' with the following settings:

2.2.1 Target collection: target_collection, Index equals value 0, Output: Output1 (new variable, text)


Repeat step 2 and 2.1 for the number of attachments you want to handle and change step 2. Expression when 'workflow variables' items_in_collection equals value X with the number and the 'Get items from Collection' as shown below

 

Eg. for 3 attachments the values will be

2. Expression when 'workflow variables' items_in_collection equals value 3

2.1 Inside the 'Run if' add a 'Get Item from Collection' with the following settings: Target collection: target_collection, Index equals value 0, Output: Output1

2.2 Inside the 'Run if' add 3 'Get Item from Collection' with the following settings:

2.2.1 Target collection: target_collection, Index equals value 0, Output: Output1

2.2.2 Target collection: target_collection, Index equals value 1, Output: Output2

2.2.2 Target collection: target_collection, Index equals value 2, Output: Output3

 

Rule is to change the Run if's according to number of attachments and then add the variable handling inside according to the number of attachments. You only need one set of variables because of the Run If's. Remember to lock the attachment max value accordingly in the attachment control in the form!

 

Step 3

Build URL variable and insert links in the mail

1. Add a 'Set workflow variable' with the following settings

1.1 Variable: Site_url (name it whatever, new variable: text)

1.2 Value: https://yoursharepointsite.sharepoint.com/value/sitename/Lists/list-name/Attachments/{Current Item: ID}/

Add your own sharepoint site values. Beware of the list name if it got spaces!

 

2. Add an 'Send e-mail' fill out accordingly. In the body hit insert link and use the following:

2.1 URL: {Variable: URL}{Variable: Output1}

2.2 Hyperlink text: {Varibale: Output1}

Repeat after wishes and/or number of attachments

 

That should be it - you're done!

 

Feel free to ask questions and/or post improvements/whatever your want!

 

/Rasmus

 

Ps. Ill try to add some more screenshots at a later time.

Pps. I don't know if this 'guide' already exists, sorry if it does.

Outcomes