Can be used with: Task, Stage and Milestone

    Required Rule - 图1

    A plan item may be required, meaning that it has to reach an end-like state before the containing stage can complete. Whether a plan item is required can be specified by a required rule.

    This rule is evaluated when the milestone, stage or task is instantiated and transitions to the state AVAILABLE, and its result value of type boolean is maintained throughout the remainder of the case instance. If this rule evaluates to true, the plan item’s parent stage instance must not transition to COMPLETED state unless the plan item is in the COMPLETED, TERMINATED or DISABLED state. For example, a task that has not yet been worked on, i.e., is in state ENABLED, prevents its containing stage to complete. If the rule is not present, then it is considered to be false.

    1. <planItem id="PlanItem_HumanTask_1" definitionRef="HumanTask_1">
    2. <itemControl>
    3. <requiredRule>
    4. <condition>${true}</condition>
    5. </requiredRule>
    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 is required.

    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. <requiredRule>
    5. <condition>${true}</condition>
    6. </requiredRule>
    7. </defaultControl>
    8. </humanTask>

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

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

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

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