Switch with like operator

Hello,

I would like to create a switch where I check the Error_Message string if it is like:

  • period
  • customer
  • country

image

This would define what type of error I got.

Could you please help me how to set up this with like operator?

Thank you.

Hello,

I’ve done something similar to this using an if condition in the expression:

For example,

If( Error_Message.ToUpper.Contains("PERIOD"),"*period*",If(Error_Message.ToUpper.Contains("CUSTOMER"),"*customer*",If(Error_Message.ToUpper.Contains("COUNTRY"),"*country*","default")))

The idea here is to have the Expression return the string that is found in a Case, and those strings can be anything of your choosing. You can also use string or regex functions to pull out portions of the Error_Message that will return a string in a Case.

There could be other ideas too.

Regards.

1 Like

Hi there @erika027,
Alternatively, you could bring that error up to a state machine level and transition there.

This will allow you to use ‘Contains’ in the transitions, as denoted above.

Though, this depends on how your project is setup.

Thanks,
Josh

1 Like