Nintex Workflow – Get File Extension UDA

Although figuring out the file type can be as simple as checking the content type, sometimes that doesn’t give us the data we need.  In this case, any document can be uploaded to a document library in SharePoint and I have a need to figure out the file type.

The easiest way I can think of, is to check the file extension.  That way, if I needed to, in my Nintex Workflow, I could use a Switch action to handle the different file types with different business logic.

I built a Nintex Workflow User Defined Action, because I can see myself using this logic in other workflows, and I don’t want to have rebuild it.

User Defined Action – Design

Here is the design.  It’s quite simple, only 5 actions.

The UDA will have 2 parameters.

1. File URL (input)

2. Extension (output)

Now granted, you could extend this, so that if you passed multiple URLs, it would give you back multiple extensions.  It wouldn’t be that hard to do… but I didn’t have that need with this UDA.

I want to highlight the important actions in this UDA.

The first being the Regular Expression.  If you don’t know already, I love this action. It’s so powerful.

Notice the expression \w+$.

The \w represents a word, but essentially it’s character.  The plus, tells it to find 1 or more characters together.  The $ sign says, look for the end of the text.  This won’t match a dot/period, which means, we should get back the file extension.

BUT!!! Since we are doing an Extract that only allows us to store the data in a Collection variable.  Which means, we need to add a little logic to the UDA, to check that we have data in the collection and if we do, pull out the first result.

The final action is a Build String action.

The reason for the Build String action, is to call the fn-ToLower inline function. This will take the file extension and make it lower case.  I wanted to do this, because from the workflow that would eventually call this UDA, I don’t want to have to check for multiple file extensions, that are essentially the same. eg. csv CSV CsV csV etc.  This UDA will send back “csv” and “docx” etc.  It will make it easier for me to use this in a Switch action later.


I hope this helps you guys.  If you have any questions, comments or suggestions, please post them in the comments below.


Nintex Workflow 2013

Download the User Defined Action – Download it and import into the New User Defined Action page

Leave a Reply

Your email address will not be published. Required fields are marked *