UiPath

How to use If, Switch, Flow Decision and Flow Switch in UiPath

In the development of UiPath Studio, there are times when I want to separate the process depending on the condition.

However, since there are multiple ways to divide the process according to conditions, many people may not know which one to use.

In this article, we will introduce how to use “If”, “Switch”, “Flow Decision”, and “Flow Switch” for activities that divide processing according to conditions.

 

 Related Articles Learn the Creation Techniques f UiPath robotics creation with Udemy’s online courses that take it up a notch

This site was created by translating a blog created in Japanese into English using the DeepL translation.

Please forgive me if some of the English text is a little strange

how to use If, Switch, Flow Decision, Flow Switch

If and Switch can be used in both Flowchart and Sequence, but they do not allow you to go back to the previous activity.

Flow Decision and Flow Switch can only be used in Flowchart to go back to the previous activity.

The table below shows the results.

activity Flowchart Sequence multiple branch Back to Previous Activity
If × ×
Switch ×
Flow Decision × ×
Flow Switch ×
F-pen
F-pen
Basically, you can use “Flow Decision” or “Flow Switch” in flowcharts, and “If” or “Switch” in sequences to create processes that are easy to understand.

 

If

If is located in the activity System>Activities>Statements.

If can be used to change the process depending on whether the condition is satisfied or not.

The expression (condition) that determines whether a condition is satisfied should be of type Boolean.

 

Sample code for an expression (condition) to determine if String types str1 and str2 match.

str1 = "abc"
str2 = "xyz"
String.Equals(str1,str2)

 

Sample Process 1
Judges whether the strings in str1 and str2 match, and outputs a “Yes” message if true, or a “No” message if false.

・Execution result 1

 

 

Sample code for an expression (condition) to determine if int2 is greater than int1 of type int

int1 = 100
int2 = 10
int1 > int2

 

Sample Process 2

・Execution result 2

If

 

Switch

The Switch is located in the activity System>Activities>Statements.

Switch is used when you want to change the process for multiple conditions.

 

Sample Process 1
It judges whether str1 is Japan, France, Brazil, or other, and executes the message box with the matching condition.

・Switch Properties

*TypeArgument is changed to String.

・Execution result 1

F-pen
F-pen
If the value of Expression matches the Case, the processing of that Case will be executed.

 

Sample Process 2
It judges whether str1 is Japan, France, Brazil, or other, and executes the message box with the matching condition.

・Switch Properties

※TypeArgument is Changed to String

・Execution result 2

sea otter
sea otter
If the value of Expression does not match any of the Cases, the Default process will be executed.

 

Flow Decision

Flow Decision can be found in Workflow > Flowchart.

Flow Decision is used when you want to change the process depending on the conditions on the flowchart.

 

Sample Process 1
Judges whether int2 is greater than int1, and processes it according to True or False.

・FlowDecision Properties

・Execution result 1

 

F-pen
F-pen
Unlike If, you can also go back to the previous activity’s process.

 

Sample Process 2
Judges whether the value of the dialog input result is less than or equal to 10, and displays an OK message box if it is true, or a message box to prompt for retyping if it is false, and returns to the dialog input.

・InputDialog Properties

 

・FlowDicision Properties

 

・Message Box Retry Properties

・Message Box OK Properties

 

・Execution result 2-1

sea otter
sea otter
Since 1<=10 of FlowDecision satisfies the equation, the process “Message Box OK” after True will be executed.

 

・Execution result 2-2


 

F-pen
F-pen
If FlowDicision is 20<=10, the condition is not satisfied, so the process “Message Box Retry” -> “InputDialog” will be executed after False.

 

Flow Switch

Flow Switch can be found in Workflow > Flowchart.

Flow Switch is used when you want to change the process depending on multiple conditions on a flowchart.

 

Sample Process
Judges whether the value of str1 matches the value of each Case, and outputs a message box where the value of str1 matches the value of Case.
If the conditions do not match, the Case with the IsDefaultCase checkbox is executed.

・FlowSwitch Properties

・Default property for branching

・France property for branching

・Japan property for branching

ペンギンさん
ペンギンさん
The branching condition can be set by clicking on the arrow and editing the Case value.

 

 

・Message Box Default

・Message Box France

・Message Box Japan

 

・Execution result

 

Summary

  • If you want to change the process depending on whether a condition is met or not, use If.
  • If you want to divide the process by multiple conditions, use Switch
  • Use Flow Decision and Flow Switch when you want to process conditions separately in a flowchart, or when you want to return to the processing of the previous activity.

Back to Table of Contents

 

 Related Articles Learn the Creation Techniques f UiPath robotics creation with Udemy’s online courses that take it up a notch

 same category UiPath

 

The operator of this blog, F-penIT blog