ServiceNow Flow Designer comparison evaluates to false even when it matches
Flow designer occasionally thinks that "value=value" is equal to false instead of true, here's why!
We ran into a problem recently in Flow Designer where we wanted to compare a dynamic result (string) with a fixed string.
We would run a custom script action, which would return a string value, say "rejected" and then do a manual "If" comparison to a fixed string value of "rejected".
So you can imagine our surprise when Flow Designer starts skipping steps, saying that "rejected=rejected" is False.
After much searching and attempts to fix the problem in a variety of different ways, we came across a solution.
The cause of our problem was Chromium browsers, apparently, they can sporadically add something known as a ZERO WIDTH NO-BREAK SPACE to the end of our fixed strings (also known as a byte order mark). This is near impossible to pick up, due to, as the name suggests, the character being zero width, ie you cannot see it.
But one method of checking your values, is to open an active flow in Operations View, copying the comparison, in our case "rejected=rejected", pasting it into the website https://regexr.com , and you may or may not come up with something like this.
See that little red dot? That's our zero width character.
To fix this, in your string comparison:
- Put your cursor on the very end of your string
- Press the Right Arrow a bunch of times
- Hit the delete button, until you get to the end of your word (or in my case, I even went one character further and then retyped the character)
Hopefully, this works for you, it did for us!