I want to use a switch statement to check a string for the words “SUCCESS” and “FAILED” So far I have
But even though the message contains “SUCCESS” It still prints out the “UNKNOWN” Status.
The full Status message looks like this.
SUCCESS DEFAULT SUCCESS
Or FAILED DUPLICATE_ORDER Duplicate order recieved
Or if it’s any other message it should say unknown, if it doesn’t contain SUCCESS or FAILED
I’m not aware of a way to use a condition as the Case, so I normally just use the condition in the Expression, like I have presented in the example. I also added .ToUpper to remove case-sensitivity.
When I typed that in, I get an error message in the Expression.
Compiler error(s) encountered processing expression
Cannot infer a common type because more than one type is possible.
So I don’t think the expression is working. But I see what you’re trying to do here, I just can’t think
of a way to express that…
I changed StatusMessage from Generic value to a String, and got rid of .ToString. in my expression, but it’s still giving me the default value instead of failed.
I’m trying to keep it short and visible, and I don’t want to have to add another workflow to my sequence. So I’m trying to use the switch statement to keep it all in site. Because I already have 5 workflows that are pretty long, I just want to shorten them up however I can.
I would say before your switch, paste your expression into a Message Box to verify what the output of the expression is returning. Also, verify that StatusMessage is in All Caps and contains the word correctly.
Can you remove the “” from the case values and try
I tried and CASE - “Failed” should be without quotes just FAILED and type you may already have as String