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

工作流活动

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

示例工作流

UiPath Studio 中的“代码片段”面板存储用户添加的 XAML 文件。示例 XAML 文件存储在文件夹中。存储长时间运行的工作流中使用的 XAML 文件的文件夹称为Orchestration

示例 XAML 文件是只读的。您需要在 Studio 中创建一个单独的流程,在其中复制代码片段中的活动和配置。

这些代码片段是使用“暂留”活动包中的可用活动创建的示例工作流。

先决条件

  • 要基于“代码片段”面板中的工作流开发长时间运行的工作流,您需要安装UiPath.Persistence.Activities包。
  • 我们建议使用“编排流程”模板开始构建长时间运行的工作流。

添加队列项目并等待完成

此代码片段将创建一个队列项目并暂停工作流,直到该队列项目的处理完成为止。

  1. “添加队列项目并获取引用”活动拖动到工作流中。

    此活动使用 In/Out 参数将队列项目添加到位于 Orchestrator 中的队列容器中。然后,它将有关新创建的队列项目对象的相应数据检索到QueueItemData类型变量中,以便暂停工作流,直到队列项目添加到队列中。有关活动的更多信息,请参见“添加队列项目并获取引用”页面

    将队列项目添加到 Orchestrator 队列后,所有 QueueItemData 类型变量都将使用从 Orchestrator 检索到的数据进行填充。

    1. “项目信息”集合中,创建一个具有“输入/输出方向”的参数,并将值设置为要作为队列项目传递的变量。在此示例中,传递一个名为Test字符串变量。
    2. “队列项目对象(输出)”属性字段中,按键盘上的CTRL + k并创建一个QueueItemData类型变量,以在 Orchestrator 中创建队列项目后存储有关队列项目的数据。在此示例中,创建一个名为QueueItemObjectQueueItemData变量。

    docs image

  2. 拖动要在工作流暂停之前运行的任何活动,以检索有关队列项目的数据。在此代码片段中,在暂停工作流之前要执行的任何步骤部分已被注释掉,充当一个容器,您可以在其中放置不会在运行时执行的活动。

  3. “等待队列项目然后继续”活动拖动到工作流中。此活动会等待在 Orchestrator 中添加和处理队列项目,以便检索相关数据并将其重新映射到工作流中的QueueItemData类型变量内。有关活动的更多信息,请参见等待队列项目然后继续页面。

    1. “队列项目对象(输入)”属性字段中,传递QueueItemObject变量,以引用要添加到 Orchestrator 的确切队列项目。
    2. “队列项目对象(输出)”属性字段中,按键盘上的CTRL + k并创建一个QueueItemData类型变量,用于在处理和检索队列项目后存储有关队列项目的数据。
  4. Add a Write Line activity into your workflow, to print out the Queue Item that you added in Orchestrator. For this example, in the Text property field, pass the Test variable.

创建外部任务并挂起直到完成

This snippet creates an External Action and suspends the workflow until the user completes the action.

  1. “创建外部任务”活动拖动到工作流中。此活动会使用给定的“任务 标题” 、“任务优先级” 、“任务目录” (现在称为“操作目录” )和“任务数据” 在 Action Center 中创建一个 外部操作 。有关活动的更多信息,请参见“创建外部任务”页面。

  2. 使用向 InOutIn/Out传递信息的参数填充“任务数据收集”属性窗口。在此示例中,创建三个参数,每个参数具有不同的“方向”InOutIn/Out 。将“类型”设置为String 。对于“值”字段,在键盘上按CTRL + K并创建三个变量,以提供信息(适用于In类型的参数)或提取信息(适用于Out类型的参数)。

    For this example, create three String type variables:

    • InVariable - the Value of the argument of type In.
    • OutVariable - the Value of the argument of type Out.
    • InOutVariable - the Value of the argument of type In/Out.

    docs image

    “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建一个ExternalTaskData类型变量。在此示例中,将变量命名为TaskPersistData 。此ExternalTaskData对象用于传递来自 Orchestrator 的数据,以便让机器人知道在完成特定的操作任务之前,工作流将暂停。

  3. 添加要在暂停工作流之前运行的任何活动,以检索有关 ExternalTaskData 对象的数据。

    1. For this example, drag and drop a Sequence activity into your workflow and populate with three Write Line activities. Each Write Line activity is meant to output the data of the three variables passed in the External Task. Pass the following values in the Text property fields: InVariable, OutVariable, InOutVariable.
  4. “等待外部任务,然后继续” 活动拖动到工作流中。此活动会暂停工作流,直到外部任务完成,然后将其重新映射到工作流的ExternalTaskData类型变量内。请参阅等待外部任务然后继续页面,了解有关此活动的更多信息。

    1. “任务对象(输入)”属性字段中,传递ExternalTaskData变量,以引用您创建的确切外部任务。对于此示例,请传递TaskPersistData变量。
    2. “任务操作”属性字段中,按键盘上的CTRL + k ,创建一个“字符串”类型变量,并将其命名为TaskAction 。这将存储用户为完成任务而采取的操作。
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL+ k ,创建一个“外部任务数据”类型变量,并将其命名为TaskData 。此变量存储外部操作完成后从 Orchestrator 中检索到的更新任务对象。
  5. Add any activities that you want to run after the workflow is resumed. For this example, print in the Output panel all the values retrieved after the completion of the External Action, using four Write Line activities. Pass the following variables in the Text fields: TaskAction, InVariable, OutVariable, InOutVariable.

    docs image

创建表单任务并暂停直到完成

此代码片段创建一个表单 Actions 并暂停工作流,直到用户完成 Actions为止。

  1. “创建表单任务”活动拖动到工作流中。此活动使用给定的“任务标题” 、“任务优先级” 、“任务目录” (现在称为“操作目录” )和“任务数据” 在 Action Center 中创建一个 表单操作 。有关该活动的更多信息,请参见“创建表单任务”页面。

  2. 使用输入输出输入/输出信息的参数填充“任务数据收集”属性窗口。在此示例中,创建三个参数,每个参数具有不同的“方向”InOutIn/Out 。将“类型”设置为String 。对于“值”字段,在键盘上按CTRL + K并创建三个变量,它们用于提供信息(对于In类型的参数)或提取信息(对于Out类型的参数)。

    For this example, create three String type variables:

    • InVariable - the Value of the argument of type In.
    • OutVariable - the Value of the argument of type Out.
    • InOutVariable - the Value of the argument of type In/Out.

    docs image

    “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建一个FormTaskData类型变量。在此示例中,将变量命名为TaskPersistData 。此FormTaskData对象用于传递来自 Orchestrator 的数据,以便让机器人知道在完成特定的操作任务之前,工作流将暂停。

  3. Add any activities that you want to run before the workflow is suspended to retrieve data about the FormTaskData object. For this example, drag and drop a Sequence activity into your workflow and populate it with three Write Line activities. Each Write Line activity is meant to output the data of the three variables passed in the External Action. Pass the following values in the Text property fields: InVariable, OutVariable, InOutVariable.

  4. “等待外部任务,然后继续” 活动拖动到工作流中。此活动会暂停工作流,直到表单操作完成,然后将其映射回工作流的FormTaskData类型变量内。

    1. “任务对象(输入)”属性字段中,传递FormTaskData变量,以引用您在 Action Center 中创建的确切表单任务。对于此示例,请传递TaskPersistData变量。
    2. “任务操作”属性字段中,按键盘上的CTRL + k ,创建一个“字符串”类型变量,并将其命名为TaskAction 。这将存储用户为完成任务而采取的操作。
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL + k ,创建一个“表单任务数据”类型变量,并将其命名为TaskData 。此变量存储任务完成后从 Orchestrator 中检索到的更新任务对象。
  5. Drag any activities that you want to run after the workflow is resumed. For this example, pass in the Output panel all the values retrieved after the completion of the External Action, using four Write Line activities. Pass the following variables in the Text fields: TaskAction, InVariable, OutVariable, InOutVariable.

创建任务并分配给用户

此代码片段将创建两个外部操作,并将其分配给用户,并显示失败操作分配的列表。

  1. Drag two Create External Task activities into your workflow.

    1. 对于第一个活动,为操作指定标题并设置其优先级。在“任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建一个ExternalTaskData类型变量。在此示例中,将其命名为Task1PersistData

    2. 对于第二个活动,为操作指定标题并设置其优先级。在“任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建一个ExternalTaskData类型变量。在此示例中,将其命名为Task2PersistData

      docs image

  2. 将两个“添加到集合”活动拖动到工作流中。

    备注:

    “添加到集合”活动是一个传统活动。要在项目中提供“添加到集合”活动,请执行以下操作:

    • Have System.Activities package 22.4.1 or lower installed.
    • 转到“活动”面板。
    • 单击“查看选项”docs image图标。
    • 单击“显示传统” 。该活动位于“默认活动” >“编程” >“集合”下。
    1. “集合”属性字段中,按键盘上的CTRL + k ,创建一个List<TaskUserAssignment>类型变量,并将其命名为TaskAssignementsInput 。转到“变量”面板,然后在“默认值”字段中将变量初始化为new List(Of TaskUserAssignment

    2. “项目”属性字段中,创建TaskUserAssignment的实例,该实例具有以下参数: “外部任务数据”变量和要向其分配任务的用户的电子邮件地址。对于此示例,请输入以下内容:

      • Thenew TaskUserAssignment(Task1PersistData.Id, "emailaddress") expression for the first Add To Collection activity
      • The new TaskUserAssignment(Task2PersistData.Id, "emailaddress") expression for the second Add To Collection activity.

      docs image

    3. “类型参数”属性设置为System.Collections.Generic.List<UiPath.Persistence.Activities.Tasks.TaskUserAssignment>

  3. Drag an Assign Tasks activity into your workflow.

    1. “任务用户分配(输入)”字段中,传递List<TaskUserAssignment>变量。对于此示例,请传递TaskAssignmentsInput变量。

    2. “任务分配类型”属性字段中,键入要执行的确切分配操作: “分配”“重新分配” 。例如,输入Assign

    3. “失败的任务分配(输出)”属性字段中,按键盘上的CTRL + k ,创建一个List<TaskAssignmentResponse>类型变量,并将其命名为FailedTaskAssignmentsOutput

      docs image

  4. 拖动“写入行”活动,以输出失败的任务分配数量。在“文本”属性字段中,传递List<TaskAssignmentResponse>类型变量,然后使用.Count.ToString属性。对于此示例,请传递以下表达式: FailedTaskAssignemntsOutput.Count.ToString

启动作业并在完成后继续

启动无人值守流程并暂停工作流,直到完成特定作业。

  1. “启动作业并获取引用”活动拖动到工作流中。此活动根据输入的参数在 Orchestrator 中启动作业,然后检索相应的作业对象。有关该活动的更多信息,请参见 “启动作业并获取引用”页面。
    1. “流程名称”属性字段中,传递要用于作业的流程的“显示名称”。在此示例中,将名称存储在变量中。按键盘上的CTRL +k ,创建一个String类型变量,并将其命名为ProcessName 。在“值”字段中,传递流程的“显示名称”,例如TestProcess_test

      备注:

      显示名称需要以以下格式写入: packageName _environment

      docs image

    2. “作业参数(集合)”属性中,创建在 Orchestrator 中调用作业时要使用的参数。此属性根据从 Orchestrator 中的作业收到的输入修改OutIn/Out类型的参数,然后将其重新映射到工作流中。对于此示例,创建一个名为Test方向In/OutString类型参数。在字段中,按键盘上的CTRL + k ,并创建String类型变量。将变量命名为Test

      docs image

    3. “作业对象(输出)”属性字段中,按键盘上的CTRL + k并创建一个名为JobPersistenceDataJobData类型变量。此变量存储调用 Orchestrator 中的作业时创建的作业数据对象,以便将其用于“等待作业然后继续”活动。

  2. 添加要在暂停工作流之前运行的任何活动,以检索有关 JobData 对象的数据。
  3. “等待作业然后继续”活动拖动到工作流中。此活动会暂停工作流,直到 Orchestrator 中的特定作业完成为止。作业完成后,工作流将继续。
    1. “作业对象(输入)”属性字段中,传递为“启动作业并获取引用” 活动创建的JobData类型变量。对于此示例,请传递JobPersistenceData变量。这会将机器人指向在恢复工作流之前需要完成的确切作业。
    2. “作业对象(输出)”属性字段中,按键盘上的CTRL + k并创建JobData类型变量。在此示例中,将其命名为JobDataObject
  4. 拖动“写入行”活动,以便打印已映射回工作流的参数。在“文本”属性字段中,传递在“作业参数(集合)”中创建的参数作为值的变量。对于此示例,请传递Test变量。

暂停并在 1 小时后恢复

此代码段会暂停给定的工作流,并在一小时后恢复。

  1. 添加要在暂停工作流之前运行的任何活动。

  2. 将“延迟后恢复”活动拖动到工作流中。此活动将暂停给定的工作流,并在指定的日期和时间恢复该工作流。请参阅“延迟后恢复”页面,了解有关此活动的更多信息。

    1. “变量”面板中,创建一个System.TimeSpan类型变量。在此示例中,将变量命名为OneHour 。将TimeSpan变量的默认值设置为New TimeSpan(1,0,0)
    2. 在活动的“继续时间”属性字段中,传递DateTime.Now表达式和TimeSpan变量。对于此示例,请传递以下表达式: DateTime.Now + OneHour

    docs image

  3. 添加要在工作流恢复后运行的任何活动。

暂停,5 分钟后继续

此代码段会暂停给定的工作流,并在五分钟后恢复。

  1. 拖动要在暂停工作流之前运行的任何活动。

  2. Drag a Resume After Delay activity into your workflow. This activity suspends the given workflow and resumes it at a specified date and time.

    1. “变量”面板中,创建一个System.TimeSpan类型变量。在此示例中,将变量命名为FiveMinute 。将TimeSpan变量的默认值设置为New TimeSpan(0,5,0)
    2. 在活动的“继续时间”属性字段中,传递DateTime.Now表达式和TimeSpan变量。对于此示例,请传递以下表达式: DateTime.Now + FiveMinute

    docs image

  3. 拖动要在工作流恢复后运行的任何活动。

挂起并在 90 秒后恢复

此代码段会暂停给定的工作流,并在 90 秒后恢复。

  1. 添加要在暂停工作流之前运行的任何活动。

  2. Drag a Resume After Delay activity into your workflow. This activity suspends the given workflow and resumes it at a specified date and time.

    1. “变量”面板中,创建一个System.TimeSpan类型变量。在此示例中,将变量命名为NinetySeconds 。将TimeSpan变量的默认值设置为New TimeSpan(0,0,90)
    2. 在活动的“继续时间”属性字段中,传递DateTime.Now表达式和TimeSpan变量。对于此示例,请传递以下表达式: DateTime.Now + NinetySeconds

    docs image

  3. 拖动要在工作流恢复后运行的任何活动。

等待所有表单任务完成

此代码片段根据数据表中的发票数量在循环中创建多个表单操作,并暂停工作流,直到所有操作都完成。

  1. “构建数据表”活动拖动到工作流中。

    1. “输出”属性字段中,按键盘上的CTRL + k并创建一个DataTable类型变量,以存储您正在构建的数据表。对于此示例,将DataTable变量命名为HighValueInvoices
    2. 单击docs image“构建数据表”窗口将打开。
    3. Column1 重命名为 InvoiceNumber ,将 Column2 重命名为 InvoiceAmount
    4. 在表格的行中添加数据,然后按“确定”。

    docs image

  2. “分配”活动拖动到您的工作流中。此活动将为数据表命名,并将其存储在String变量中。

    1. “目标”属性字段中,传递DataTable变量。对于此示例,请传递HighValueInvoices变量。
    2. “值”属性字段中,在键盘上按CTRL + k ,然后创建String类型变量。在此示例中,将其命名为DataTableName 。将DataTableName变量的默认值设置为“invoices”。
  3. “遍历循环”活动拖动到工作流中。在“项目列表”属性字段中,传递以下格式的表达式: DataTableVariable.Rows 。在此示例中,传递HighValueInvoices.Rows 。这将遍历数据表中的每一行。

  4. Drag a Create Form Task activity inside the Body of the For Each activity.

    1. “任务标题”属性字段中,输入“遍历循环”活动检索到的“发票编号” 值,并将其转换为字符串。对于此示例,输入以下表达式: item("InvoiceNumber").ToString ,其中InvoiceNumber是保存每张发票相应编号的列的名称。
    2. 表单数据(集合)中,创建一个参数,以在表单操作中传递每个发票金额。创建一个String类型参数,并将“方向”设置为In 。在“值”字段中,输入每个发票的金额并将其转换为字符串。对于此示例,输入以下表达式: item("InvoiceAmount").ToString ,其中InvoiceAmount是保存每张发票相应金额的列的名称。
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建一个FormTaskData类型变量。在此示例中,将变量命名为TaskPersistData

    docs image

  5. Drag an Add To Collection activity inside the Body of the For Each activity.

    1. “集合”属性字段中,按键盘上的CTRL + k ,创建一个List<FormTaskData>变量,并将其命名为TaskList 。转到“变量”面板,然后在“默认值”字段中将变量初始化为New List(Of UiPath.Persistence.Activities.FormTask.FormTaskData
    2. “项目”属性字段中,传递FormTaskData变量,创建该变量是为了存储有关创建的表单操作的数据。对于此示例,请传递TaskPersistData变量。
    3. 对于“类型参数”属性,选择UiPath.Persistence.Activities.FormTask.FormTaskData
  6. Drag a Parallel For Each activity into your workflow.

    1. 对于“类型参数”属性,选择UiPath.Persistence.Activities.FormTask.FormTaskData
    2. “值”属性字段中,传递List<FormTaskData>变量。对于此示例,请传递TaskList变量。
  7. “等待表单任务并继续”活动拖动至“并行的遍历循环”活动的主体。

    1. “任务对象(输入)”属性字段中,输入“并行的遍历循环”活动中引用的item对象。在本例中, item对象表示存储在TaskList变量中的表单操作。
    2. “任务操作”属性字段中,按键盘上的CTRL + k并创建一个String变量。在此示例中,将其命名为TaskAction
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建FormTaskData变量。在此示例中,将其命名为TaskData

    docs image

  8. Drag a Write Line activity into your workflow. This activity displays in the Output panel the action taken by the user to complete the Form Action. In the Text value, input the TaskAction variable.

等待任何表单任务完成

此代码片段按顺序创建多个表单 Actions ,并暂停工作流,直到完成任何表单 Actions 为止。

  1. Drag a Create Form Task activity into your sequence workflow.

    1. “任务标题”属性字段中,按键盘上的CTRL + k并创建一个String变量。将其命名为TaskTitle1 。在“变量”面板中,将默认值设置为"Task - " + "Approver 1"
    2. “表单数据(集合)”属性中,创建类型String方向In的参数。将参数命名为Approver ,并将设置为"Approver1"
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建FormTaskData变量。在此示例中,将变量命名为TaskPersistData1
  2. Drag a second Create Form Task activity into your workflow.

    1. “任务标题”属性字段中,按键盘上的CTRL + k并创建一个String变量。将其命名为TaskTitle2 。在“变量”面板中,将默认值设置为"Task - " + "Approver 2"
    2. “表单数据(集合)”属性中,创建类型String方向In的参数。将参数命名为Approver ,并将设置为"Approver2"
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建FormTaskData变量。在此示例中,将变量命名为TaskPersistData2
  3. Drag a third Create Form Task activity into your workflow.

    1. “任务标题”属性字段中,按键盘上的CTRL + k并创建一个String变量。将其命名为TaskTitle3 。在“变量”面板中,将默认值设置为"Task - " + "Approver 3"
    2. “表单数据(集合)”属性中,创建类型String方向In的参数。将参数命名为Approver ,并将设置为"Approver3"
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建FormTaskData变量。在此示例中,将变量命名为TaskPersistData3
  4. Drag a Pick activity into your workflow.

  5. Drag a Pick Branch activity into the body of the Pick activity. Rename the activity as Pick Branch (Task1).

  6. Drag a Wait For Form Task And Resume activity into the Trigger body of the Pick Branch (Task1) activity.

    1. “任务对象(输入)”属性字段中,传递为存储有关表单操作的数据而创建的FormTaskData变量。对于此示例,请传递TaskPersistData1变量。
    2. “任务操作”属性字段中,按CTRL + k并创建String变量。将其命名为TaskAction1
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL+ k并创建FormTaskData变量。将其命名为TaskData1
  7. Drag a Write Line activity into the Action body of the Pick Branch (Task1) activity. This activity is meant to display in the Output panel the action taken by the user to complete the Form Action. In the Text value, input the TaskAction1 variable.

    docs image

  8. Drag a Pick Branch activity into the body of the Pick activity. Rename the activity as Pick Branch (Task2).

  9. Drag a Wait For Form Task And Resume activity into the Trigger body of the Pick Branch (Task2) activity.

    1. “任务对象(输入)”属性字段中,传递为存储有关表单操作的数据而创建的FormTaskData变量。对于此示例,请传递TaskPersistData2变量。
    2. “任务操作”属性字段中,按CTRL + k并创建String变量。将其命名为TaskAction2
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL+ k并创建FormTaskData变量。将其命名为TaskData2
  10. Drag a Write Line activity into the Action body of the Pick Branch (Task2) activity. This activity displays in the Output panel the action taken by the user to complete the Form Action. In the Text value, input the TaskAction2 variable.

  11. Drag a Pick Branch activity into the body of the Pick activity. Rename the activity as Pick Branch (Task3).

  12. Drag a Wait For Form Task And Resume activity into the Trigger body of the Pick Branch (Task3) activity.

    1. “任务对象(输入)”属性字段中,传递为存储有关表单操作的数据而创建的FormTaskData变量。对于此示例,请传递TaskPersistData3变量。
    2. “任务操作”属性字段中,按CTRL + k并创建String变量。将其命名为TaskAction3
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL+ k并创建FormTaskData变量。将其命名为TaskData3
  13. Drag a Write Line activity into the Action body of the Pick Branch (Task3) activity. This activity displays in the Output panel the action taken by the user to complete the Form Action. In the Text value, input the TaskAction3 variable.

在循环中等待某些表单任务完成

此代码片段根据数据表中的输入创建多个表单 Actions,并暂停工作流,直到完成一组特定的表单 Actions 。

  1. Drag a Build Data Table activity into your workflow.

    1. “数据表”属性字段中,在键盘上按CTRL + k ,然后创建一个System.DataTable变量。在此示例中,将其命名为CodeReviews
    2. 单击docs image“构建数据表”窗口将打开。
    3. Column1重命名为ReviewerName ,将Column2重命名为ReviewerType 。将ReviewerType列的类型设置为String
    4. 在表格的行中添加数据。对于ReviewerType列,此示例使用两种类型的审核人:代码所有者审核人

    docs image

  2. Drag an Assign activity into your workflow. This assigns a name to the data table you created. In the To property field, pass the System.DataTable variable and add .TableName property to it. In the Value field, press CTRL + k on your keyboard and create a String variable. For this example, name it DataTableName.

  3. Drag a Parallel For Each activity into your workflow. For this example, name it Create Tasks for PR Review.

    1. “值”属性字段中,传递System.DataTable变量并添加.AsEnumerable属性。对于此示例,请传递以下表达式: CodeReviews.AsEnumerable
  4. “分配”活动拖动至“并行遍历循环”活动的“主体”。

    1. 目标属性字段中,在键盘上按CTRL + k并创建一个String变量,用于保存从CodeReviews数据表的ReviewerType列中检索到的数据。在此示例中,将变量命名为ReviewerType
    2. “值”属性字段中,传递一个表达式,该表达式该表达式从ReviewerType列中检索每个行项目并将其存储在“至”字段内创建的变量中。对于此示例,请传递以下表达式: ìtem("ReviewerType").toString

    docs image

  5. Drag a Create Form Task activity into the Body of the Parallel For Each activity.

    1. “任务标题”属性字段中,传递以下表达式: "Code Review - " + InPullRequestNameInPullRequestNameString变量,具有默认"#1"
    2. “表单数据(集合)”属性中,创建四个类型String参数:
    3. “PR 号” - 将“方向”设置为“ In ”,并将“值”设置为InPullRequestName
    4. Reviewer Name - “方向”设置为In“值”设置为item("ReviewerName").toString
    5. Reviewer Type - 其中“方向”In/Out ,且值设置为“ ReviewerType变量。
    6. Reviewer Comment - 且方向Out 。在“值”字段中,按键盘上的CTRL + k并创建一个String变量。将其命名为ReviewerComments 。此参数会将操作中的所有注释映射到工作流中。
    7. “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建FormTaskData变量。将其命名为TaskPersistData

    docs image

  6. Drag an Add To Collection activity into the body of the Parallel For Each activity. This activity stores all the Form Actions created into a list.

    1. “集合”属性字段中,在键盘上按CTRL + k并创建一个List<FormTaskData>变量。将其命名为TaskDataList 。转到“变量”面板,然后将变量的“默认值”设置为New List(of UiPath.Persistence.Activities.FormTask.FormTaskData)
    2. “项目”属性字段中,传递FormTaskData变量。对于此示例,请传递TaskPersistData变量。
    3. 对于“类型参数”属性,选择UiPath.Persistence.Activities.FormTask.FormTaskData
  7. In the Variables panel, create two variables of type Int32 and set their Default value to 0: OwnersApprovals and ReviewersApprovals.

  8. 拖动另一个“并行遍历循环”活动。在此示例中,将其命名为Wait for Conditional Task(s) Completion

    1. “条件”属性字段中,传递以下表达式: OwnersApprovals>=2 Or (OwnersApprovals = 1 And ReviewersApprovals>=2) 。这会使工作流仅在满足条件时恢复。
    2. 对于“类型参数”属性,选择UiPath.Persistence.Activities.FormTask.FormTaskData
    3. “值”属性字段中,传递存储表单操作的列表。对于此示例,请传递TaskDataList变量。

    docs image

  9. “序列”活动拖动到“等待条件任务完成”活动的“主体”中。将其重命名为Wait for Task and Resume

  10. “等待表单任务然后继续”活动拖动到“等待任务然后继续”序列活动中。

    1. “任务对象(输入)”属性字段中,传递item变量。
    2. “任务操作”属性字段中,按键盘上的CTRL + k并创建一个String变量。在此示例中,将其命名为TaskAction
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建FormTaskData变量。在此示例中,将其命名为TaskData
  11. Drag an If activity into the Wait for Task and Resume sequence activity. This activity is meant to count the number of Form Actions that have been approved by code owners.

    1. “条件”属性字段中,传递以下表达式: TaskAction="approve" And ReviewerType="code owner"
    2. “分配”活动拖放到Then块中。在“目标”属性字段中,传递OwnersApprovals变量。在“值”属性字段中传递OwnersApprovals + 1表达式。

    docs image

  12. Drag another If activity into the Wait for Task and Resume sequence activity. This activity is meant to count the number of Form Actions that have been approved by reviewers.

    1. “条件”属性字段中,传递以下表达式: TaskAction="approve" And ReviewerType="reviewer"
    2. “分配”活动拖动至Then块。在“目标”属性字段中,传递ReviewersApprovals变量。在“值”属性字段中传递ReviewersApprovals + 1表达式。

    docs image

  13. 将三个“写入行”活动拖动到“等待任务然后继续序列”活动中。此活动会在“输出”面板中显示给定值。

    1. 在第一个活动中,传递 ReviewComments 变量。
    2. 在第二个活动中,传递 OwnersApprovals 变量并添加 .toString 属性。
    3. 在第三个活动中,传递 ReviewersApprovals 变量并添加 .toString 属性。

等待某些表单任务完成

此代码段创建三个表单操作并暂停工作流,直到完成两个操作。

  1. Drag a Create Form Task activity into your sequence workflow.

    1. “任务标题”属性字段中,按键盘上的CTRL + k并创建一个String变量。将其命名为TaskTitle1 。在“变量”面板中,将默认值设置为"Task - " + "Approver 1"
    2. “表单数据(集合)”属性中,创建类型String方向In的参数。将参数命名为Approver ,并将设置为"Approver1"
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建FormTaskData变量。在此示例中,将变量命名为TaskPersistData1
  2. Drag a Create Form Activity into your sequence workflow.

    1. “任务标题”属性字段中,按键盘上的CTRL + k并创建一个String变量。将其命名为TaskTitle2 。在“变量”面板中,将默认值设置为"Task - " + "Approver 2"
    2. “表单数据(集合)”属性中,创建类型String方向In的参数。将参数命名为Approver ,并将设置为"Approver2"
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建FormTaskData变量。在此示例中,将变量命名为TaskPersistData2
  3. Drag a Create Form Activity into your sequence workflow.

    1. “任务标题”属性字段中,按键盘上的CTRL + k并创建一个String变量。将其命名为TaskTitle3 。在“变量”面板中,将默认值设置为"Task - " + "Approver 3"
    2. “表单数据(集合)”属性中,创建类型String方向In的参数。将参数命名为Approver ,并将设置为"Approver3"
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL + k并创建FormTaskData变量。在此示例中,将变量命名为TaskPersistData3
  4. Drag a Parallel activity into your workflow.

    1. “条件”属性字段中,按键盘上的CTRL + k并创建一个Int32变量。在此示例中,将变量命名为CompleteTasksCount ,并将默认值设置为0
    2. “条件”属性内的“表达式编辑器”中,将条件设置为CompleteTasksCount=2 。这是在三个操作中完成两个后,并行活动完成的条件。

    docs image

  5. Drag a Sequence activity into the body of the Parallel activity. Rename the activity as Sequence Task1.

  6. In the Sequence Task1 activity, drag a Wait For Form Task and Resume activity. Rename it as Wait for Form Task and Resume(Task1).

    1. “任务对象(输入)”属性字段中,传递为存储有关表单操作的数据而创建的FormTaskData变量。对于此示例,请传递TaskPersistData1变量。
    2. “任务操作”属性字段中,按CTRL + k并创建String变量。将其命名为TaskAction1
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL+ k并创建FormTaskData变量。将其命名为TaskData1

    docs image

  7. Drag a Write Line activity into the Action body of the Sequence Task1 activity. his activity is meant to display in the Output panel the action taken by the user to complete the Form Action. In the Text value, input the TaskAction1 variable.

  8. “赋值”活动拖动到Wait for Form Task and Resume(Task1)活动中。在“目标”字段中传递CompleteTaskCount ,并在“值”字段中传递CompleteTaskCount +1 表达式。如果操作已完成并且工作流已继续,则向CompleteTaskCount变量添加一个新的迭代。

    docs image

  9. Drag a Sequence activity into the body of the Parallel activity. Rename the activity as Sequence Task2.

  10. Sequence Task2活动中,拖放“等待表单任务然后继续”活动。将其重命名为Wait for Form Task and Resume(Task2)

    1. 在“任务对象(输入)” 属性字段中,传递为存储有关表单操作的数据而创建的“表单任务数据” 变量。 在此示例中,传递 TaskPersistData2变量。
    2. “任务操作”属性字段中,按CTRL + k并创建一个字符串变量。将其命名为 TaskAction2
    3. “任务对象(输出)”属性字段中,按键盘上的 CTRL + K 键并创建一个FormTaskData变量。将其命名为TaskData2
  11. Drag a Write Line activity into the body of the Sequence Task2 activity. This activity displays in the Output panel the action taken by the user to complete the Form Action. In the Text value, input the TaskAction2 variable.

  12. “赋值”活动拖动到Wait for Form Task and Resume(Task2)活动中。在目标字段中传递CompleteTaskCount ,并在字段中传递CompleteTaskCount + 1表达式。如果操作已完成并且工作流已继续,则向CompleteTaskCount变量添加一个新的迭代。

  13. Drag a Sequence activity into the body of the Parallel activity. Rename the activity as Sequence Task3.

  14. In the Sequence Task3 activity, drag and drop a Wait For Form Task and Resume activity. Rename it as Wait for Form Task and Resume(Task3).

    1. “任务对象(输入)”属性字段中,传递为存储有关表单操作的数据而创建的FormTaskData变量。对于此示例,请传递TaskPersistData3变量。
    2. “任务操作”属性字段中,按CTRL + k并创建String变量。将其命名为TaskAction3
    3. “任务对象(输出)”属性字段中,按键盘上的CTRL+ k并创建FormTaskData变量。将其命名为TaskData3
  15. Drag a Write Line activity into the Action body of the Sequence Task3 activity. his activity is meant to display in the Output panel the action taken by the user to complete the Form Action. In the Text value, input the TaskAction3 variable.

  16. “赋值”活动拖动到Wait for Form Task and Resume(Task3)活动中。在目标字段中传递CompleteTaskCount ,并在字段中传递CompleteTaskCount + 1表达式。如果操作已完成并且工作流已继续,则向CompleteTaskCount变量添加一个新的迭代。

此页面有帮助吗?

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