What the Use Case for a Switch vs Flow Switch

Hi all,

I’m confused by the difference between a switch and a flow switch. When do I use a switch, and when do I use a flow switch?

Can anyone point me to some examples that show the difference between a switch and a flow switch?

Thanks,
Fritz

1 Like

Hey @Hibb

Switch Activity:

The Switch activity evaluates a specified expression and executes the activity from a collection of activities whose associated key matches the value obtained from the evaluation.

A Switch activity contains an Expression and a dictionary of Cases. Each case in the dictionary consists of a pair that contains a key and an activity that serves as its corresponding value. The Switch activity evaluates the Expression and compares it against each of the keys. If a match is found, the corresponding activity is executed. Only one match is possible because dictionary keys must be unique according to the type of equality defined by the equality compare of the dictionary. If no match is found, the Default activity is executed.

Example: SwitchCase.xaml (5.8 KB)

FlowSwitch:
A FlowSwitch activity works like a FlowDecision except instead of being restricted to a True and False branch. Each branch of a FlowSwitch activity is called a FlowStep.

The FlowSwitch activity is a conditional node that provides branching for the flow of control based on match criterion when more than two alternative branches are required. If the flow branching requires only two paths, use the FlowDecision activity instead.

The FlowSwitch<System.int32>("In uipath) activity contains an Expression that returns a value of type Int32 when evaluated. The activity also contains a set of Cases, which specifies a unique mapping from possible results of this evaluation to a set of FlowNode objects. The FlowNode executed is the one whose object of type int32 matches the value of the evaluated Expression. A Default case can (optionally) be provided for the case in which no match is obtained.

Example: FlowSwitchName.xaml (11.7 KB)

Regards…!!
Aksh

22 Likes

Thanks Aksh - that’s exactly what I needed to know.

I appreciate you getting back to me so quickly. As always, you’re a wealth of information and I appreciate you sharing it.

Regards, Fritz

1 Like

Pleasure is all mine :slight_smile: @Hibb

Regards…!!
Aksh

2 Likes

Is there a limit of the number of keys you could have in the Switch activity? In a FlowSwitch it seems that there are only 11.

1 Like

Hey @selrac
I am also not aware with the limit part. It should depend on the Type passed to it and compiler for the translation.
May be if you will pass an Int then it should have supported Int values cases.

Not found relevant info as well. May be someone else have some solid info on this, then that will be good.

I don’t see anything but the amount of memory available limiting it.

With flow switch i m able to use more then 11 branches easily… :slight_smile:

Regards…!!
Aksh