Nintex Workflow – Replacing in a Collection UDA
I’m going to do a quick post today, since it’s time to head home from the awesome Nintex InspireX event in Las Vegas.
I had the question of replacing some text in all the values in a Collection.
Imagine having a collection with values like:
a123
b234
x456
and you want to remove all the 3 digit numbers and just be left with the raw alpha values.
a
b
x
I built a User Defined Action to do this:
This UDA will take two parameters, an Input and Output Collection. Usually, when you use this UDA, you’ll be using the same collection variable for both input and output.
Notice they are both collection types. This is awesome, because I can read/parse the input collection, then store everything in the Output collection and my workflow can continue on.
So what makes up this UDA? It’s actually quite simple. The really hardcore part of this UDA, is the Regular Expression, which you’ll see in a moment. But in order to work on, I like to store my collection in a Text variable. It’s probably not really necessary, but I find I like to do it this way, especially if I need to make so tweaks to the text, before passing it to the Regular Expression.
textTempData is a temporary variable. I usually put the word “temp” in the names of my variables, if I plan to reuse them in other actions, without carrying how they were used previously.
Notice the Regular Expression below:
I’m using an expression \d{3}. This says, look for numerical digits in groups of 3, and replace them with nothing. In essence, remove all group of 3 digits.
This is the action you would use, to modify the text for your solution. This UDA by itself, is most likely not going to be 100% solution for you. You will need to tweak it a bit.
Finally, we split the text by semi-colon and store it back in the output parameter.
In the downloads section below, I included the Workflow and the UDA. The workflow simply uses a Regular Expression to populate a collection variable. Simply for quick design/text of the UDA.
When using the UDA, you’ll find it interesting, that I use the same collection variable in both the input and output parameters.
Above, you see how to use the UDA in your workflows.
Time to fly…