activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

工作流活动

上次更新日期 2026年2月20日

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(旧版跨平台

配置

  • “条件” - 单击字段右侧的“加号”docs image然后从菜单中选择“条件生成器” ,以定义执行Then分支中的活动的条件。或者,您可以选择 Excel 文件,然后选择带有条件语句的单元格,或者可以选择“在高级编辑器中打开”以输入 VB 表达式。

在条件生成器中:

  • 加号中选择第一个值。docs image找到左侧字段的菜单。您可以从项目笔记本、父级 Excel 文件或 Outlook 帐户(Excel 中的单元格、Outlook 邮件中的字段)中选择数据(Excel 中的单元格、Outlook 邮件中的字段),使用先前保存的另一个活动的输出值以供日后使用,输入文本或数字。

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

  • 如果适用,从“加号”框中选择用于与第一个值进行比较的第二个值。docs image找到右侧字段的菜单。例如,要添加条件“Excel 单元格 B6 中的值大于 10”,对于在 Excel 中指明B6单元格的第一个值,您可以选择“大于”作为运算符,然后输入数字10作为第二个值。

    docs image

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”分支中的活动,这在我们的示例中配置为“在“消息框”活动中显示剪贴板的值。

docs image

解决竞争条件

观察到的行为

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

原因

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

分辨率

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

备注:

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

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

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2026 UiPath。保留所有权利。