Vadim Tabakman

Jump to bottom

Nintex Workflow - Get Attachment Urls UDA

It sounds like this might be difficult, but as it turns out, it's really not bad at all.  What we are trying to do here, is get access to the urls of the documents that were attached to an Item or Task in SharePoint.  In fact, building a Nintex Workflow User Defined Action (UDA) to do this seems a little odd, since the UDA contains only two actions.

What's was that you just said?  You don't know what a User Defined Action is and why you would want to use it?  Well, take a look at this : What is a User Defined Action?

What does the UDA do?

There are a important components of this UDA. 

1. We need to specify some parameters.  Two input parameters (ListName and the ItemID) and an output parameter (Collection of Urls).

UDA Parameters

2. Next we need a Call Web Service action.  This will allow you to query the item and pull out the Urls of the attachments on the item.

SharePoint exposes a http://msdn.microsoft.com/en-us/library/lists.lists(v=office.12).aspx web service, which in turn has a GetAttachmentCollection web method.

*** WARNING *** - the Call Web Service is configured to use a Nintex Workflow Constant called Farm Admin.  In order to use this UDA, you need to create a constant with that name, or use an existing one and update this Call Web Service action.

Call Web Service

3. Finally in this UDA, we have a Query XML action.  This is used, because the result of the web service call above, is an XML chunk and we need to extract the Urls from that, using an XPath expression.

Query XML

4. The result is a UDA that looks like this.

UDA Design

Without repeating what is in the "What is a User Defined Action?" post, I'll just say that the two reasons why I chose to make this into a UDA, are that it makes it easier for me to share it with you, and also that not everyone has access to the Call Web Service action, so this is a nice way to hide it from end users, but still give them the ability to do this.

Using this User Defined Action

Simply dragging this action to a workflow and configuring it with the current list and item and storing the urls in a Collection variable is very easy.

Here is what the workflow looks like :

Workflow Design

By looking at the UDA action configuration, you'll see it's quite easy to configure, even for end users.

UDA Usage

The final part of the workflow is simply iterating through the Collection of Url results and logging them to the Workflow History.  You can do what you want in the For Each loop, but this is just to show all the urls and show you how to iterate through it. 

What Does the Output Look Like?

The following is what a list item looks like with a number of attachments:

Item Properties

When we run the workflow on this item, this is what the workflow history looks like:

Workflow History

This can be also used to get attachment urls for documents that were attached to a Workflow Task.

Downloads

Posted by Vadim Tabakman Thursday, March 20, 2014 12:00:00 PM Categories: Call Web Service For Each Log in the History List Nintex Workflow Nintex Workflow 2013 Query XML User Defined Actions
Copyright Vadim Tabakman
Rate this Content 0 Votes

Comments

Monday, May 11, 2015 7:48:59 AM
Tarre
Gravatar

re: Nintex Workflow - Get Attachment Urls UDA

Hi Vadim,

I have a workflow that has many tasks and can have attachments to the tasks at a few points. I got this UDA and workflow to work on the list item itself, but have not found a way to have it pull back URLs for tasks associate to that item.

The tasks have their own unique ID but no way to know what that will be until the task is created. Have you done anything like that before? Any help would be greatly appreciated.

Tarre

Monday, May 11, 2015 7:52:02 AM

re: Nintex Workflow - Get Attachment Urls UDA

Hi Tarre,

 

check the task action you are using, since it will probably let you store the Task ID in a workflow variable, that you can then use in the UDA.

cheers,

Vadim

Monday, May 11, 2015 8:56:51 AM
Tarre
Gravatar

re: Nintex Workflow - Get Attachment Urls UDA

Thanks Vadim!

Some of the tasks create multiple, so I would need to put those in a collection variable and then split those out and then do a for each to save all of them separately...Does that sound about right?

Thanks Again!

Monday, May 11, 2015 10:50:20 AM

re: Nintex Workflow - Get Attachment Urls UDA

Yeah that sounds exactly what you will need to do.

cheers,

Vadim

Tuesday, May 12, 2015 12:00:29 PM
Tarre
Gravatar

re: Nintex Workflow - Get Attachment Urls UDA

One more question.

I got the task part working...Thanks for the help!!

When I log it in the history list, it shows me when I have multiple attachments, but when I try to do anything else, like put the link in a notification or make the link an attachment, to a notification, it only attaches the first one.

Any ideas how to separate out the attachments and capture them all anywhere but the history list?

Thanks,

Tarre

Tuesday, May 12, 2015 1:23:38 PM

re: Nintex Workflow - Get Attachment Urls UDA

Hi Tarre,

you need to get the attachment urls into a collection variable.

The latest version of Nintex Workflow supports sending notifications with dynamic number of attachments.  You simply pass it the collection variable.

cheers,

Vadim

Wednesday, May 13, 2015 8:47:30 AM
Tarre
Gravatar

re: Nintex Workflow - Get Attachment Urls UDA

Ok. When I do that, I get the full string of URLs, but it breaks the link at the first space. The links are also separated by semi colons. Do I correct how I want those to appear with a regular expression?

Tarre

Wednesday, May 13, 2015 9:17:40 AM

re: Nintex Workflow - Get Attachment Urls UDA

Yeah that's a good idea.  That's the way I would do it.

cheers,

Vadim

Thursday, May 14, 2015 1:21:08 PM
Tarre
Gravatar

re: Nintex Workflow - Get Attachment Urls UDA

Hi Vadim,

I am not having any luck splitting this string by the semicolon delimiter. I have looked through your post on Regular Expression in Nintex and have not had any success, all the other sites refer to other styles of writing regex and are just not working. Can you help me figure this out? Here is my string:

WebURL/Lists/MyList/Attachments/18/attachment1.txt;WebURL/Lists/MyList/Attachments/18/attachment2.txt;WebURL/Lists/MyList/Attachments/18/attachment 3.txt (yes the last attachment has a space)

I currently do not have any attachments with spaces in them, but I know my users in the future will, so I am trying to plan and avoid those errors. If the space breaks the link, I am fine with that, I can fix that part later

Any suggestions would be greatly appreciated.

Tarre

 

Friday, May 15, 2015 7:29:23 AM

re: Nintex Workflow - Get Attachment Urls UDA

Hi Tarre,

if you add a Reg Ex action, for the pattern just add a semi-colon, for the operation, select Split and for the text set it your urls, then you should be able to store the urls into a collection variable.

cheers,

Vadim

Thursday, July 16, 2015 8:12:35 AM
Tarre
Gravatar

re: Nintex Workflow - Get Attachment Urls UDA

Hi Vadim,

Splitting using the semicolon in the regular expression never worked out for us. It still gave us the list of attachment urls with a semicolon delimiter. One of our architects suggested using <br> as our output was in an html format.

We used the expression to replace the semicolons with the <br> and it worked.

Just wanted to share in case anyone else has trouble.

Thanks for all of your help!

Tarre

Thursday, July 16, 2015 11:33:44 AM

re: Nintex Workflow - Get Attachment Urls UDA

Hi Tarre,

 

it depends on how you use the collection.  If you then use the collection in a Log action or an email body, yes it will semi-colon delimit it.

But wit the collection, if you needed to parse each value, you an use a Fir Each, then put together some HTML that is really cool

 

cheers,

Vadim

Tuesday, November 3, 2015 6:16:16 AM

re: Nintex Workflow - Get Attachment Urls UDA

Hi Vadim,

I get all of the URLs from specific list item - this is really great.

In the next step I have to attach the Attachements to new e-mail via worklfow. Unfortunately I am not able to add them as an attachment. I am only able to print the link in the mail text.

Is there any option to reattach the files to a mail?

Thanks in advance

 

Dirk

 

Wednesday, November 4, 2015 1:43:17 PM

re: Nintex Workflow - Get Attachment Urls UDA

Hi Dirk,

I thought there's been an update to Nintex Workflow that allows you to add a collection variable and it recognizes it.

CAn you reach out to Nintex Support for this?

cheers,

Vadim

Wednesday, February 17, 2016 10:02:21 AM
Amanda
Gravatar

re: Nintex Workflow - Get Attachment Urls UDA

Hi Vadim,


I want to do something similar but different - attach a document in a document library to a list item. Is there a resource somewhere on how to do this?

Thanks,

Amanda

Wednesday, February 17, 2016 2:28:34 PM

re: Nintex Workflow - Get Attachment Urls UDA

Hi Amanda,

interesting.  Yes you can.  You would need to run a workflow on the document itself.  That workflow would use the Call Web Service action to call the Lists.asmx web service.  Specifically, the AddAttachment method.  In the "attachment" field of the web method, you would put in [FileData].  This tells Nintex Workflow to take the current document and put that Base64 data of it, into this packet.

You'll find this being discussed here: https://community.nintex.com/thread/4972

Hope that helps.

Vadim

Friday, March 18, 2016 8:31:40 AM

re: Nintex Workflow - Get Attachment Urls UDA

Hi Vadim,

 

I managed to get the workflow to write the URL's to the workflow history list successfully thanks. How do I now display the attachments as hyperlinks in a Nintex task form that is generated when the item in question is saved. I'm no Nintex expert however so some pointers on how to do this would be great.

 

Thanks in advance

Chet

Wednesday, April 6, 2016 7:37:11 AM
Toe
Gravatar

re: Nintex Workflow - Get Attachment Urls UDA

Brilliant as always!

Thursday, June 16, 2016 3:05:01 AM
Yasmin
Gravatar

re: Nintex Workflow - Get Attachment Urls UDA

Hi Vadim,

I have tried this but it seems the update action only update one attachment. The last loop.

How do I update the rest of attachment url in my list?

Thank you.

Thursday, June 16, 2016 7:08:23 AM

re: Nintex Workflow - Get Attachment Urls UDA

Hi Yasmin,

this article is about getting the URLs.  I'm not updating anything here.  What do you mean by updating the rest of the attachments?

cheers,

Vadim

Thursday, June 16, 2016 9:30:36 PM
Yasmin
Gravatar

re: Nintex Workflow - Get Attachment Urls UDA

Hi Vadim,

I get the URL and I want to update the URL on my list.

For example user add two attachment, I added update item action in the loop but at the end only last loop will be update in the list.

Do you know how can I update the two attachment URL in my list?

Thank you.

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register
  • RSS





 

Statistics

  • Entries (235)
  • Comments (1721)

Categories