Flow Designer If statements and strings and choice fields

Daniel Peel
Mega Sage

San Diego Patch 7

I've been trying to do a flow since our patch and no matter the combo I try ... I can't get string values to compare correctly in IF statements if that string starts out as part of a choice field.

 

For example... I have a sub-flow that is setting the "choice" value from an approval to a "string" flow variable.  So approved, rejected, skipped etc.  Then the sub-flow is returning that "string" variable back to the main flow and I'm asking if "string" variable does not contain approved.  So when it runs... it sees approved NOT LIKE approved = true.  

 

I've even set the returned value with a f(x) .toLowerCase() and the choice field value when putting it in the flow variable

 

main flow return
DanielPeel_0-1665692727624.png
sub-flow setting the variable

DanielPeel_1-1665692781346.png



I've tried others too... they always involve a choice field (or glide_lists)... and even setting the choice field .toLowerCase() or adding a +"" to the end of the field... If statements seem to be not seeing the text correctly


In this one I set the return value from the subflow manually to approved and it worked fine.

DanielPeel_2-1665692983073.png

 

Am I missing something or is anyone else having issue with that... 

 

3 REPLIES 3

Soeren Maucher
Mega Sage

Hello @Daniel Peel

I recently had the same issue accross multiple instances (Rome and San Diego). 
To me this looks like a serious bug on ServiceNow side but I have not found any official documentation yet. 
Basically using String comparison in If statements is not working properly. I found two workarounds: 
1. Delete the if statement, clear cache, reopen flow designer, and recreate it again. Repeat this process until it works. In one case I did this multiple times and suddenly it worked. However I would not suggest doing this, because I am not sure if it will still work if you deploy the changes via update set to another instance. 
2. Not use String comparisons in if statement. In your case I think you can actually drag and drop the state choice directly to the if condition and then select the desired state: 

community3.PNG
In case the condition is more complicated my current work around is writing a simple action where I scripted the condion and then return either "true" or "false" which I will then use in the if condition. I know its not a nice solution, but from my point of view using String comparison in if statements is currently not reliable. 

I hope this helped!

Greetings, 
Sören

Maik Skoddow
Tera Patron
Tera Patron

Hi @Daniel Peel 

please check whether the bug I have described at https://www.servicenow.com/community/now-platform-blog/do-not-run-into-that-weird-flow-designer-bug/... might also apply to your scenario.

Maik

piotrj_szurek
Tera Contributor

Hi

I've just noticed exactly the same behavior of our flow. Flows that were created before the upgrade works flawlessly. Only the one I've started to build is wrongly evaluating conditions.  It seems to be quite a serious bug.