Can be used with: Task, Stage

Manual Activation Rule - 图1

Whether the actual work of a task or stage can be performed depends on its entry criteria. Given that an entry criterion is fulfilled, there are two ways to activate a task:

  • By manual activation
  • By automatic activation
    Automatic activation is the default behavior in which it is not required that a user manually activates a task. In camunda, manual activation can be done by using the CaseService API with caseService.manuallyStartCaseExecution(caseExecutionId). By specifying a manual activation rule, it is possible to omit this step or make it depend on case variable payload. With manual activation, a user can decide to activate a task or instead disable it. A task that is automatically activated must be carried out.

In XML, a manual activation rule can be specified for an individual plan item or for a plan item definition. For a plan item it looks as follows:

  1. <planItem id="PlanItem_HumanTask_1" definitionRef="HumanTask_1">
  2. <itemControl>
  3. <manualActivationRule>
  4. <condition>${true}</condition>
  5. </manualActivationRule>
  6. </itemControl>
  7. </planItem>
  8. <humanTask id="HumanTask_1">
  9. </humanTask>

The specified expression ${true} evaluates to the boolean value true and means that the plan item should become active in only through the human intervention.

For a plan item definition, the following XML can be used:

  1. <planItem id="PlanItem_HumanTask_1" definitionRef="HumanTask_1"/>
  2. <humanTask id="HumanTask_1">
  3. <defaultControl>
  4. <manualActivationRule>
  5. <condition>${true}</condition>
  6. </manualActivationRule>
  7. </defaultControl>
  8. </humanTask>

The rule specified in the humanTask element is valid for all plan items that reference it, here PlanItem_HumanTask_1.

Tricky Specification

Automatic activation is the default behavior. Thus, by specifying the element manualActivationRule you can express exceptions from that default for cases in which a task does need a manual activation.

As with any expression, you can use case variables to determine the result of a manual activation rule. The following snippet expresses that manual activation is required when a variable var has a value greater than 100:

  1. <manualActivationRule>
  2. <condition>${var > 100}</condition>
  3. </manualActivationRule>

In terms of the task/stage lifecycle, manual activation corresponds to the transition from AVAILABLE to ENABLED when an entry criterion occurs, and from ENABLED to ACTIVE when the task is manually activated. In contrast, automatic activation corresponds to the direct transition from AVAILABLE to ACTIVE that fires immediately when an entry criterion occurs.

原文: https://docs.camunda.org/manual/7.9/reference/cmmn11/markers/manual-activation-rule/