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).
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.
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.
4. The result is a UDA that looks like this.
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 :
By looking at the UDA action configuration, you'll see it's quite easy to configure, even for end users.
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:
When we run the workflow on this item, this is what the workflow history looks like:
This can be also used to get attachment urls for documents that were attached to a Workflow Task.