A human task is defined in XML as follows:

A human task in state can be started manually using the CaseService as follows:

  1. caseService.manuallyStartCaseExecution("aCaseExecutionId");

When the human task becomes ACTIVE, a new task is created in the task list of the user(s) or group(s) assigned to that task.

If the work associated with the human task is done, it is possible to complete the human task manually using the CaseService as follows:

  1. caseService.completeCaseExecution("aCaseExecutionId");

This completes the created task as well.

Instead of using the CaseService it is also possible to use the TaskService to complete a human task:

  1. taskService.complete("aTaskId");

Properties

In that case the associated human task is completed as well.

A human task can have a description. In fact, any CMMN 1.1 element can have a description. A description is defined by adding the description attribute.

    Due Date

    Each task has a field indicating the due date of that task. The Query API can be used to query for tasks that are due on, before or after a certain date.

    There is an extension attribute that allows to specify an expression in a task definition to set the initial due date of a task when it is created. The expression should always resolve to a java.util.Date, java.util.String ( formatted) or null. When using ISO8601 formatted Strings, you may either specify an exact point in time or a time period relative to the time the task is created.

    1. <humanTask id="theTask" name="Important task" camunda:dueDate="${dateVariable}"/>

    The due date of a task can also be altered using the task service or in task listeners using the passed delegate task.

    Each task has a field indicating the follow up date of that task. The Query API can be used to query for tasks that need to be followed up on, before or after a certain date.

    There is an extension attribute that allows you to specify an expression in a task definition to set the initial follow up date of a task when it is created. The expression should always resolve to a java.util.Date, java.util.String (ISO8601 formatted) or null. When using ISO8601 formatted Strings, you may either specify an exact point in time or a time period relative to the time the task is created.

    1. <humanTask id="theTask" name="Important task" camunda:followUpDate="${dateVariable}"/>

    User Assignment

    A human task can be directly assigned to a single user, a list of users or a list of groups.

    Assignment using CMMN Case Role

    CMMN defines some native assignment concepts which can be used in Camunda.As a more powerful alternative, Camunda also defines a set of custom extension elements (see below).

    The CMMN concept of performerRef can be used to assign a task to a single user. The attribute references an existing role. Such a role definition needs a name that defines the user.

    Only one user can be assigned to the task as a performer. This user is called the assignee. Tasks that have an assignee are not visible in the task lists of other users and can only be found in the personal task list of the assignee.

    1. List<Task> tasks = taskService.createTaskQuery().taskAssignee("kermit").list();

    When strictly following the CMMN standard, user and group assignments can be quite cumbersome for use cases where the assignment is more complicated. To avoid these complexities, custom extensions on the human task element can be set.

    The CMMN Human task supports the same assignment extensions and concepts as the BPMN User Task.You can read up on these extensions in the . Same as for the BPMN User task, assignment based on data and service logic is supported for the CMMN Human Task as well.

    Forms

    It is possible to provide information to render a human task form by using the camunda:formKeyattribute:

    1. <humanTask id="someTask" camunda:formKey="someForm.html">
    2. ...
    3. </humanTask>

    The form key is a symbolic value which can be set in the CMMN XML file by using the extensionattribute formKey and retrieved at runtime using the process engine API.

    If the user task form is displayed inside the Camunda Tasklist, the format of the formKey must followspecial rules. .

    In custom applications, the value of the form key can be chosen freely. In a custom application thevalue of the form key attribute can be interpreted freely. Based on the specific UI technology used,it can reference the name of an HTML file, a JSF / Facelets template, a Vaadin / GWT view, …

    Retrieving the form key using the form service.

      When performing a task query, it is possible to retrieve the form key as well. This is most usefulif the form keys need to be retrieved for a complete list of tasks:

      Note that it is required to call the .initializeFormKeys() method on the TaskQuery object tomake sure the form keys are initialized.

      Camunda Extensions