'OR' Boolean Operator for text strings

How do I write the equivalent of:

(If [[ repeaterValueA ]] contains [[ ‘alphaNumeric1’ || ‘alphaNumeric2’ ]])

Not sure if contains is perhaps not compatible with Boolean operators, or if Boolean operators cannot contain alpha / alphanumeric values.

Workaround

I ended up just adding another repeater column with a binary value (true / false) and evaluate that since the question has a binary answer.

However I would still like to know how to use the ‘||’ operator (‘or’ operator) for 2 or more alphanumeric values.

Reference(s)

How to write ‘OR’ command for multiple text on widget condition

If this is for a conditional case then you can add two separate conditions and change “ALL” (&&) to “ANY” (||) in the condition editor.

ANY
If value [[X]] contains [[something]]
If value [[X]] contains [[somethingelse]]

The case will be executed if either of those conditions are true.

Yes, but I forgot to mention I had another condition that should be evaluated separately from these two conditions.

If it weren’t for other condition, your suggestion would work.

Off the top of my head you could try:

If value [[repeaterValueA.indexOf(‘alphaNumeric1’) + repeaterValueA.indexOf(‘alphaNumeric2’)]] is greater than or equal to -1

If neither string is contained in the first, both should return -1 which will sum to -2 so the condition will be false. If the string starts with one and doesn’t contain the other they should return 0 and -1 respectively so they will sum to -1 and the condition will be true.

There might be a cleaner way but I think this should at least work.

1 Like

Thanks @nkrisc,
I have a good feeling your suggestion will work. Haven’t tried it, but I’ve bookmarked your answer so I can use it in the future.

The “cleaner way” I think would have been the way I wrote it, however it doesn’t work. I doubt there is a better way than the way you suggested based on Axure’s structure, but I could be wrong.

There might be a bug with Boolean operators if they are supposed to work with alpha or alphanumeric characters. In which case, the way I wrote it may work at some point.

The reason why I believe your way doesn’t work is because the comparison will almost always be true unless both are empty strings. Axure does weird things when comparing strings, but generally any string with character will be “truthy” meaning the Boolean comparison 'string1' || 'string2' is true. While '' || '' would be false. It’s not comparing them in the way you think it is. What you really want is something more like:

if (repeaterValueA == 'string1' || repeaterValueA == 'string2') {/*something*/}

Throwing in your other condition it’s something like:

SomeOtherValue && (repeaterValueA == 'string1' || repeaterValueA == 'string2')