Iterate through documents in a Document Set

So, I’m a big fan of working with metadata (SharePoint views FTW!) instead of logical hierarchies (folders = boo!) and, on several occasions, I have found myself needing to run an action (a review task or approval perhaps) against all of the documents inside of a SharePoint Document Set.   But when I navigate to the Document Set I encounter a long and somewhat ugly URL for the set itself and begin the tedious work of recording the URL’s for each document.


So how can I quickly retrieve all of the document URL’s?    Enter Nintex Workflow, a few action configurations and voilà!


Our Document Library (Doc Lib A in this case), which has been configured with a Document Set content type, and our first Document Set (Test Document Set A).  For realism, I’ve sprinkled it with a few Word documents, with fascinating names (such as the timeless, Test Doc 1-4!).

Then we open the Nintex Workflow Designer and create a new workflow…

For this exercise I will simply be recording each items URL in the workflow history. But, you could use your imagination here… Another scenario with the URL’s would be populating an email notification where users would need to review a document based on its metadata. Another could be that each document in the set would need to be copied to another location for a publishing or retention process, so we would need to collect its location for additional workflow actions.

Building the Workflow

First, we need to create some variables to store our data:

  • textDocSetRaw – A text variable to store each documents Context Item URL.
  • textDocSetName – A text variable to store the isolated and cleaned up Document Set name.
  • colDocument – A collection to store the list of all of the documents inside of the set.
  • textDocumentUrl – A text variable to store each documents URL.

Then we build out the workflow to perform the following tasks:

  1. Extract the Document Set Name
  2. Remove the %20’s in the name and replace them with spaces
  3. Remove the open in browser string
  4. Query our library for all of the documents in the particular set
  5. Record the URL for each document in the workflow history of the Document Set



We can now run this workflow against a specific Document Set and it will return the URL for each document inside. This is a handy tool for my SP bag. Maybe yours now?


Download an exported version of this Workflow now



Tags: , , , , , , ,

About Brad Orluk

Brad is a Nintex Technical Evangelist with over 15 years of IT architecture, administration and sales experience. As an Information Architect at a Fortune 500, he has worked on business and IT process improvement and automation on a variety of real world global projects and productivity initiatives.  Brad’s unique, technical yet business focused, background gives him the ability to help users leverage technology to drive value to their businesses.

3 responses to “Iterate through documents in a Document Set”

  1. cedricneo says :

    Great post Brad ! Thanks for sharing. Would it be possible to send the documents from a doc set as attachments rather than sending the URL via a Nintex WF ? The WF Action send email allows attachment but how would you pass the documents from the doc set to this action ? Thanks in advance!

    • Brad Orluk says :

      Thanks, Cedricneo! You’re welcome. Yes, it would be possible to send the documents as attachments. First off, you would need to be using a newer version of Nintex Workflow ( or later) as there were some enhancements made to attachment handling in the Send Notification action. Then, instead of using a For each loop (unless you want to send an email for each document), just replace it with a Send Notification action and check the ‘Attach file from workflow’ option and insert the reference to the collection variable that contains the URL’s for the documents.

Leave a Reply

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

You are commenting using your 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

%d bloggers like this: