Task Node

Overview

The Task node represents work that requires human interaction within a workflow. When the workflow execution reaches a Task node, it pauses and waits for a user to complete the assigned task through the graphical interface. Tasks are assigned to specific users or groups of users, who interact with workflow forms to provide input and advance the process.

Configuration Tabs

The Task node configuration is organized into two tabs:

  • Task: Contains the main task properties, form definition, and assignment logic
  • Task notification: Configures email notifications sent to users when tasks are assigned

Task Tab Properties

PropertyTypeDescription
Name Text

The name that identifies this Task node. This name should clearly describe the task purpose (e.g., "Approve invoice", "Review document", "Complete form").

Id Number

Unique identifier assigned to the node. This value is automatically generated by the system and uniquely identifies the node within the process definition.

Due date Days / Hours

Sets the task deadline relative to when it is assigned to a user. Only the Days and Hours fields are editable. The system automatically generates an ISO 8601 duration format (e.g., entering 2 days and 3 hours produces P2DT3H). The due date is calculated from the moment the task is assigned to a user.

Repeat Days / Hours

Defines the interval for recurring overdue notifications. When a task becomes overdue and this field is not empty, the system sends an email notification and recalculates the next due date by adding this interval to the current date. This process repeats until the task is completed.

Source position Dropdown

Defines the position from which outgoing transition arrows exit the node. Available options: Top, Bottom, Left, Right.

Target position Dropdown

Defines the position where incoming transition arrows enter the node. Available options: Top, Bottom, Left, Right.

Description Textarea

Optional field for providing additional details or documentation about the task's purpose and requirements.

Form definition

XML Editor

Defines the form that users will interact with when completing this task. The form is defined using XML according to the OpenKM workflow form specification. For detailed information about form structure and available elements, refer to the form definition documentation section.

The editor provides three tools accessed via icons above the textarea:

  • Edit (maximize): Opens the form definition in a popup window for easier editing
  • Graphical designer: Opens a visual form builder interface
  • Preview: Shows a preview of how the form will appear to users based on the current definition

The editor supports autocomplete functionality. Press Ctrl+Space while typing to display available options and code suggestions.

Assign expression

Script Editor

Contains the script that determines which user(s) will be assigned this task. The script can return:

  • String: A single user ID for direct assignment
  • List: Multiple user IDs for pooled task assignment 

When a list of users is returned, the task becomes a pooled task. Any user in the pool can claim the task exclusively through the graphical interface, making themselves the sole assignee.

Important: The Source position and Target position cannot have the same value. For example, if Source position is set to "Bottom", Target position cannot also be "Bottom". 

Task Notification Tab Properties

PropertyTypeDescription
Notify Toggle

Enables or disables email notifications when the task is assigned to a user. When enabled, the assigned user receives an email notification indicating they have a pending task to complete.

Subject Text

The email subject line for task assignment notifications.

Body Rich Text Editor

The email body content for task assignment notifications. Supports rich text formatting including bold, italic, lists, and other formatting options.

Form Variables and Context

When a user completes and submits a task form, the form field values are automatically saved to the workflow context variables using the field's name attribute.

For example, a form field defined as:

<input label="Invoice number" name="invoiceNumber" />

Will create a context variable named invoiceNumber containing an Input object with the value entered by the user.

Important: If a context variable already exists with the same name as a form field, it will be overwritten with the new value when the user submits the form.

Due Date Behavior

The due date mechanism works as follows:

  • The due date countdown begins when the task is assigned to a user
  • When a task becomes overdue, an email notification is sent to the assigned user
  • If the Repeat field contains a value, a new due date is automatically calculated by adding the repeat interval to the current date
  • This process continues, sending notifications at each repeat interval, until the user completes the task

Assignment Expression Examples

Example 1: Simple Assignment

Assigns the task directly to a specific user:

// Assign to user "okmAdmin"
return "okmAdmin";

Example 2: Pooled Assignment

Creates a pooled task that can be claimed by any user in the list:

// Pooled task for multiple users
import java.util.*;

List users = new ArrayList();
users.add("okmAdmin");
users.add("joe");
return users;

Example 3: Assign to Workflow Initiator

Assigns the task to the user who started the workflow:

// Assign to the user who initiated the workflow
import com.openkm.sdk4j.impl.OKMWebservices;
import com.openkm.sdk4j.bean.*;
import com.openkm.okmflow.util.*;
import com.openkm.okmflow.bean.*;
import com.openkm.bean.form.*;
import com.openkm.util.*;

Class baseLibrary = ScriptUtils.evaluateFromNode("library_global_base");
def initiatorId = baseLibrary.getInitiatorId(context);
return initiatorId;

Example 4: Assign to Users with Specific Role

Creates a pooled task for all users who have a specific role:

// Assign to all users with ROLE_ADMIN
import com.openkm.sdk4j.impl.OKMWebservices;
import com.openkm.sdk4j.bean.*;
import com.openkm.okmflow.util.*;
import com.openkm.okmflow.bean.*;
import com.openkm.bean.form.*;
import com.openkm.util.*;
import java.util.*;

OKMWebservices ws = WebservicesHelper.getInstance();
List<String> users = new ArrayList();
for (CommonUser commonUser : ws.auth.getUsersByRole("ROLE_ADMIN")) {
  users.add(commonUser.getId());
}
return users;

Form Definition

Forms are defined using XML syntax according to the OpenKM workflow form specification. The form defines the fields and structure that users will interact with when completing the task. 

For comprehensive information about form structure, available field types, validation rules, and advanced features, please consult the Workflow forms definition documentation section.

Best Practices

  • Use clear, descriptive task names that indicate what action users need to take
  • Set realistic due dates based on the complexity of the task and user workload
  • Configure meaningful notification emails with clear subject lines and helpful body content
  • Test assignment expressions thoroughly to ensure users are correctly assigned
  • Document complex assignment logic in the Description field
  • Use pooled tasks when any user from a group can handle the task, rather than requiring a specific individual
  • Consider the impact of variable name collisions when designing forms - use unique, descriptive names