An if statement is a conditional statement that, if proved true, will perform a certain task, and if proved false, will do something else. If statements are one of the foundational concepts in programming and allow an automation to make decisions while it’s running. They enable a single course of action, out of two separate options depending on if a statement is true or false.
If statements contain three major components, a Condition, a Then section, and an Else section:
- Condition – Contains the conditional statement to prove true or false. Must be a Boolean data type.
- Then – This section is where you place activities to perform if the condition is true.
- Else – This section is where you place activities to perform if the condition is false.
What Does An If Statement Look Like?
How to use an If Statement in UiPath?
In UiPath, if statements can be added to automations using either one of two activities, the If activity when using a sequence or a Flow Decision activity when using a flowchart. To learn more about sequences and flow charts, click here. Let’s take a look at what these two activities look like:
- IF activity – used for if statements in sequences.
- Flow Decision – used for if statements in flowcharts.