Activities
latest
false
Banner background image
Workflow Activities
Last updated Apr 29, 2024

Else If

UiPath.Core.Activities.IfElseIf

Enables your project to take multiple different courses of action, depending on whether a series of specified conditions are met. This activity contains a Condition, a Then branch, optional Else If branches and an Else branch. The Condition field must contain a Boolean expression according to which either the Then, Else orElse If branches are executed. The Then branch comprises the activities to be performed if the condition is true. The optional Else and Else If branches comprise the activities to be performed if the first condition is false. To add additional Else If branches or an Else branch, click Add Else If or Else in the body of the activity and select the desired branch.

This activity does not need to be nested inside of an If activity.

Project compatibility

Windows | Windows - Legacy | Cross-Platform

Configuration

  • Condition - Click Plusdocs image on the right side of the field and then, from the menu, select Condition Builder to define the condition according to which either the activities in the Then branch are executed. Alternatively, you can select an Excel file and then a cell with a conditional statement, or you can select Open in Advanced Editor to enter a VB expression.

In the Condition Builder:

  • Select a first value from the Plusdocs image menu for the field on the left. You can select data from the Project Notebook, a parent Excel file or Outlook account (cells in Excel, fields in Outlook messages), use the output value of another activity that you previously saved for later, enter text or numbers.
  • Select an operator from the drop-down menu in the middle to evaluate the first value: greater than, greater than or equal, less than, less than or equal, equal to, not equal to, is empty, is not empty, is true, is false, starts with, ends with, contains.
  • If applicable, select a second value with which to compare the first value from the Plusdocs image menu for the field on the right. For example, to add the condition "the value in the Excel cell B6 is greater than 10", for the first value you indicate the B6 cell in Excel, you select is greater than as the operator, and you enter the number 10 as the second value.


To add multiple conditions, click Add in the Condition Builder and provide the same information for each additional statement. When you add multiple statements, a drop-down menu appears at the top of the window where you must select when the condition is met: All (AND) if the condition is met when all of the statements are true, or Any (OR) if the condition is met when any of the statements is true.

  • Then - Contains the activities that are executed if the condition in the Condition field is met.
  • Add Else If or Else - Select whether you want to add an Else If or Else branch:
    • Else If - Contains another Condition field that allows you to select a different set of conditions that are checked if the first condition was not met, and a Then branch where you can add activities to execute if the Else If condition was met. You can add more Else If branches depending on how many sets of different conditions you need.
    • Else - Contains the activities that are executed if none of the conditions above are met. You cannot add additional Else If branches after an Else branch.

Advanced Options

Options
  • DisplayName - The name displayed for the activity in the Designer panel.
  • Condition - See Condition in the body of the activity.
  • Private - If selected, the data used in the activity is not logged.

Example of the Else If activity:

In the example below, the value saved in the clipboard is checked three times, if it is greater than 510, or 15. If the first condition is not met, the next condition is checked. This happens until all Else if branches have been checked.

If none of the conditions in the Else if branches are met, the activities in the Else branch are executed, which in our example is configured to display the value of the clipboard in a Message Box activity.



Resolving race conditions

Observed Behavior

Else IF conditon is being triggered even though only Then condition is validated when CurrentRow is used and index=0.

Cause

The activity evaluates all conditions first before actually executing the activity.

Resolution

Add a logical operator, such as AndAlso in the Else IF condition to skip the index position 0.

Note:
Before the Else If activity is actually executed, all conditions are evaluated first. This can cause side-effects like exceptions. To avoid this, add extra checks in the ELSE condition.

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.