01-18-2022 04:03 AM
We have a Router Snap that evaluates a string and checks whether it matches one of a set of predefined values. I can’t seem to get the expressions right and think a short circuit evaluation is at play here?
The logic is as follows
The logic I started with before looking at the contains and includes functions
Will a basic course in javascript help increase accessibility when building expressions in SnapLogic?
Solved! Go to Solution.
01-18-2022 04:14 AM
Hi @NAl,
The second expression is wrong because that way if the Status is ‘X’ or ‘Y’ or ‘Z’ it will return true to both outputs.
You should change the second expression to $Status != "X" && $Status != "Y" && $Status != "Z"
, this way it will only evaluate to true if status is neither x, y nor z.
Also first expression should be: $Status == "X" || $Status == "Y" || $Status == "Z"
01-18-2022 04:14 AM
Hi @NAl,
The second expression is wrong because that way if the Status is ‘X’ or ‘Y’ or ‘Z’ it will return true to both outputs.
You should change the second expression to $Status != "X" && $Status != "Y" && $Status != "Z"
, this way it will only evaluate to true if status is neither x, y nor z.
Also first expression should be: $Status == "X" || $Status == "Y" || $Status == "Z"
01-18-2022 04:19 AM
Hey @NAl ,
If you need to match the exact value of Status, than Jovanche’s expression will do the job, if you need to check if the Status field contains X,Y or Z, than you should go with the following expression:
$Status.contains('X') || $Status.contains('Y') || $Status.contains('Z')
and for the opposite situation, you can check the ‘First Match’ option, and enter true
as a second expression.
01-18-2022 06:19 AM
Amazing! It’s now routing as expected. Thank you both for your inputs