Question

Set a condition not working. String contains string

  • 14 December 2023
  • 1 reply
  • 74 views

Userlevel 3
Badge +8

Hi all,

I have a set a condition action that isn’t working and I can't figure out why. I’m doing an LDAP query to gather members of an AD group. I’m setting a collection variable then doing an collection operation to Join with a ; delimiter and saving the results as a string, “StrADGroupMembers”. I’ve tried contains and contains ignoring text, but it still isn’t catching it. I’m sending the variables to myself in an email and the group members “StrADGroupMembers” clearly contains the employee value “StrEmployeeDisplayName”. Any ideas on what I may be doing wrong?  It’s driving me bonkers.

 

 


1 reply

Userlevel 5
Badge +14

I tried to recreate this the best I could using made up data, so while it won’t be exactly 1:1 with your environment, it should at least help to establish some sort of reliable test.


Spoiler, I wasn’t able to get it to fail, but I have some troubleshooting ideas way down below this in the section marked “Troubleshooting” (so you don’t have to read all of this if you don’t wanna)

 

Sanity Check To Make Sure It Can Be Done

 

I started by making a new workflow, and some variables:

 

var_Names_Collection will represent a collection of 8 names

 

var_NamesString will represent that same collection of names joined using a semicolon (;) as a delimeter

 

var_TargetName will represent *some* name that I’m looking for within the var_NamesString string

 

var_NameFound will tell me if var_TargetName was successfully found within var_NamesString

 

var_RandomNumber and var_RandomInteger are needed because I wasn’t sure how the TargetName (or in your case StrEmployeeDisplayName) would be given a value, I decided to make some variables that will help me get a random number so I can use it to populate var_TargetName with a random entry from our collection (var_Names_Collection)

 

First thing I do is get a random number between 0 and 7. This is just something that I have to do if I wanna test my condition against a random name from the collection. For transparency I am putting the info here, but this is not important to the issue you’re facing!

 

Current Time returns a value of how many seconds have elapsed since 1/1/1900. Using Modulo (% 8) on it will give me some value between 0 and 7.???

 

Because var_RandomNumber will equal a value that starts with a single digit, I can use the substring function to grab that starting digit, and convert it into an Integer proper, giving me a good index to use later

 

Random junk out of the way, now I need to make a collection of some names. I can do that by manually adding a few names (in this case, 8) to a collection var_Names_Collection. Once I’m finished, I can then Join the items in the collection and save it to var_NamesString:

 

 

 

Now I need to assign a value to var_TargetName, and test to see if whichever name it picks is in the string at var_NamesString:

 

Showing how var_TargetName gets its value
 

And here is how my Condition is configured: 

 

If the name is found, then we set var_NameFound to Yes, otherwise we set it to No

 

Here are three results from an email I send myself at the end:

 

So far it looks like everything is working as intended, so at least we know that something like this *can* work. However if it wasn’t, here are a few things I would check.

 

Troubleshooting

 

First I would see about stripping everything around the string that you’re searching for. So, something like “Johnson, David ;” becomes just “Johnson, David”.

 

To do this you could use the Regular Expression action with the pattern of

\s*(?=\s*;);

 

This ensures that StrEmployeeDisplayName is free of any trailing junk characters

 

This would result in the name value being stripped of anything that comes after the last character:

 

If that doesn’t work, then I would recommend doing something like pasting the values of what you’re getting back in your email into an online tool like this non-printable character finder: https://www.soscisurvey.de/tools/view-chars.php

 

What this will do is show you precisely which characters make up the value of what it is you’ve pasted into it. Why does this matter? Sometimes when working with Nintex Workflow Actions, it has been known to arbitrarily insert invisible characters into reference values, which makes doing comparative conditions like the one you’re trying to do nearly impossible (ask me how I know!).

Here is a string that looks like what you were showing in your example:

Johnson, David‎ ;

 

but if we put it into the site / tool linked above and have it show us the characters, we see that there is something strange about it:

 

That’s a special unicode character squeezed between the “d” and the space, that is practically invisible to us, but would ruin any sort of conditional check being made to match against a list of names!

 

An example of clean inputs:

no special purple characters :)

 

If neither one of these things work, then we can try digging into how your actions are setup to make sure something isn’t being overlooked or configured in a way that’s making this not do what you want it to do.

 

Let me know what you find!

Reply