If all other "ifs" are false then do this

Hi everyone,

I need some help with figuring out how to handle the following situation:

I am trying to fill out a form and need to click the checkbox that relates to a certain string variable I have. Currently I have a sequence of 10 different “if” functions that use (variable.contains(“xyz”)). If none of these if functions return true I need it to click the “other” box and input the variable in that box.

Here is a rough idea of what I have:

  1. if (variable.contains(“retail”)) - true(clicks retail box), else(continues on)

  2. if (variable.contains(“construction”)) - true(clicks construction box), else(continues on)

  3. if (variable.contains(“wholesale”)) - true(clicks wholesale box), else(continues on)

If none of the above return as true then I need to check the other box and input the variable. If one of them returns true I obviously don’t want to check other.

I have tried using the “try catch” function but I can’t put the other part under finally because then it will always check that box.

Appreciate the help!

Ok, here is an idea:

Create a variable say “Counter” assign it 0, if one of the ifs is true add 1 to “Count”.

At the end of the 10 ifs check the “Count”, if it is greater than 0 it means one of the conditions in the ifs is true, otherwise all conditions in ifs are “False”.

Let me know if it works

1 Like

You can use a For Each then inside the For each have your IF condition

Hey,

what you are looking for is the Flow Switch activity!

Instead of several nested if functions, you can define cases depending on what is in your variable and have a default case to handle everything else - neat! :smile:
I have attached a sample workflow with an easy example. Feel free to ask, if something is unclear.
FlowSwitchDemo.xaml (12.3 KB)

Cheers,
Lukas

1 Like