Query Inside a Doc Set for Specific Documents to Convert to PDF

I came across an interesting (and unexpected) challenge today and thought I would share my solution in case there are others out there who may be facing a similar set of requirements.

The Business Scenario

We have a document library with Document Sets enabled and there is a WF that runs on each Doc Set. At a certain point in the WF there is a requirement to find all documents inside the doc set that are a certain content type and create a new PDF document in the Doc Set.

Easy-peasy, right?

Turns out, it was not as straightforward as I was thinking it would be. Allow me to explain…

The Unexpected Issue

The first issue I ran into was getting the Query List action to look inside of the Doc Sets – which is a pretty big issue considering that pretty much the entire solution is dependent on that capability. Because I knew the Recursive setting in the Query List action allows the action to query inside of folders and subfolders, I assumed it would also work to look inside of our Doc Set.

Wrong! It wasn’t returning anything.

So, to the Google I went.

Luckily, I found this post by Nintex Technical Evangelist, Vadim Tabakman which saved me a ton of time and I was able to follow his trick to edit the CAML query to allow the Query List action to look inside my Doc Set.

Now, it is worth mentioning at this point that an experienced CAML coder (is that a thing?) might be able to add the filtering functionality that I needed right into the CAML query. Since I am not the most experienced when it comes to writing custom CAML queries (ex-artist remember) I made it happen with the tools I feel most comfy with – my Nintex actions!

My Solution

Once I got my Query List action updated to look inside of my Doc Set (thanks again Vadim!), I stored all the document item IDs into a collection variable and configured a For Each action to loop through each ID.

For each ID, I did another query to get the CT, Encoded Absolute URL, and Name of the document. Then, I added a Run If and configured it to run if the CT matched the specific one I was looking for.

Inside the Run If I did a quick cleanup with Regular Expression to replace the document extension with .pdf and then used the Convert Document action to convert the doc from its current format to a PDF.

That’s it! The final WF is below as well as the Convert Document action configuration.

I also added lots of logging to the WF history via the Common tab in the action settings and the Log in History List action to make sure I was getting back the data I was expecting at every step along the way. See my previous post if you are not familiar with the Common settings.


One thought on “Query Inside a Doc Set for Specific Documents to Convert to PDF

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s