UiPath Documentation
activities
latest
false

工作流活动

上次更新日期 2026年5月11日

Else If

UiPath.Core.Activities.IfElseIf

使项目能够根据是否满足一系列指定条件,采取多个不同的操作过程。该活动包含一个条件、一个Then分支、可选的Else If分支和一个Else分支。“条件”字段必须包含执行“Then”、 “Else”“Else If”分支的布尔值表达式。Then分支包含条件为 true 时要执行的活动。可选的ElseElse If分支包含第一个条件为 false 时要执行的活动。要添加其他Else If分支或Else分支,请在活动主体中单击“添加 Else If”或“Else” ,然后选择所需分支。

此活动无需嵌套在If活动中。

项目兼容性

Windows |旧版 | Windows - Legacy(旧版)| Windows - Legacy(旧版跨平台

配置

  • Condition - Click Plus文档图像 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.

在条件生成器中:

  • Select a first value from the Plus文档图像 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.

  • 从中间的下拉菜单中选择一个运算符,以评估第一个值:大于、大于或等于、小于、小于或等于、等于、不等于、为空、不为空、为 true , 为 false,表示开头为、结尾为、包含。

  • If applicable, select a second value with which to compare the first value from the Plus文档图像 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” - 包含不满足上述任何条件时执行的活动。您不能在Else分支之后添加其他Else If分支。

高级选项

选项
  • DisplayName - The name displayed for the activity in the Designer panel.
  • “条件” - 在活动正文中 查看“条件” 。
  • Private - If selected, the data used in the activity is not logged.

Else If 活动示例:

在下面的示例中,如果保存在剪贴板中的值大于51015 ,则系统会检查保存在剪贴板中的值三次。如果不满足第一个条件,则检查下一个条件。在检查了所有Else if分支之前,都会发生这种情况。

如果“Else if”分支中的任何条件均不满足,则执行“Else”分支中的活动,这在我们的示例中配置为“在“消息框”活动中显示剪贴板的值。

解决竞争条件

观察到的行为

在使用CurrentRowindex=0时,即使仅验证Then条件,也会触发Else IF条件。

原因

该活动在实际执行活动之前首先评估所有条件。

分辨率

Else IF 条件中添加逻辑运算符(例如 AndAlso)以跳过索引位置 0。

备注:

在实际执行 Else If 活动之前,系统会先评估所有条件。这可能会导致异常等副作用。为避免这种情况,请在 ELSE 条件中添加额外的检查。

  • 项目兼容性
  • 配置
  • 高级选项
  • 解决竞争条件

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新