如何将多实例用户任务更新为 add/delete 任务?

How to update MultiInstance User Task to add/delete Tasks?

我们有一个业务场景,我们希望能够在多实例上下文中增加或删除任务。 我已经成功地创建了一个基于集合的多实例用户任务 workPartnerList

如果流程在工作流的多实例阶段工作 - 我如何根据 workPartnerList 的 count/values 增加或减少多实例状态,而 workPartnerList 可以增加或减少基于来自 API 电话的更新。 (我们需要在整个任务完成之前执行此操作)?

我假设您指的是并行 multi-instance 任务。

https://docs.camunda.org/manual/latest/reference/bpmn20/tasks/task-markers/

Another way to define the number of instances is to specify the name of a process variable which is a collection using the loopDataInputRef child element. For each item in the collection, an instance will be created

实例的创建发生在执行达到并行 multi-instance activity 的时间点。创建的实例数由该特定时间点的集合大小决定。 (BPMN2 流程引擎不会自动保持任务实例与集合同步。)

要“删除”任务实例,您可以完成或取消它们(例如通过附加的边界事件)或我们完成条件。

A multi-instance activity ends when all instances are finished. However, it is possible to specify an expression that is evaluated every time one instance ends. When this expression evaluates to true, all remaining instances are destroyed and the multi-instance activity ends, continuing the process. Such an expression must be defined in the completionCondition child element.

要向 运行 流程实例动态添加其他任务实例,您可以使用实例事件子流程或将边界事件附加到任务。

https://docs.camunda.org/manual/7.13/reference/bpmn20/events/message-events/#message-boundary-event

Boundary events are catching events that are attached to an activity. This means that while the activity is running, the message boundary event is listening for named message. When this is caught, two things might happen, depending on the configuration of the boundary event:

Interrupting boundary event: The activity is interrupted and the sequence flow going out of the event is followed.

Non-interrupting boundary event: One token stays in the activity and an additional token is created which follows the sequence flow going out of the event.

如果您愿意在 API 水平上解决这个问题,那么 TaskService allows you to create a new task(使用用户定义的任务 ID)。 例子: https://github.com/rob2universe/cam-multi-instance/blob/25f524be6a112deb1b4ae3bb4f28a35422e428e0/src/test/java/org/camunda/bpm/example/ProcessJUnitTest.java#L79

迁移 API 甚至允许您向已创建的任务实例集添加其他实例 - 请参阅:https://docs.camunda.org/manual/latest/user-guide/process-engine/process-instance-modification/#modify-multi-instance-activity-instances