Toggle menu

Task Chaining

Task chaining lets you join user activities together, assigning a subsequent task in the same workflow directly to a user when they complete a preceding task.

Enabling Chaining

To enable chaining, open the "Advanced" tab of the user task activity you would like to chain to. Click on "Task listeners". From the default behaviour drop-down select "Allow Chaining" and press the plus icon, then save.

Chaining Task Listener

The Assignee

The task being chained to must be assigned directly to a user rather than a group/user candidate. How you supply the name of the assignee will depend on the design of your process.

The initiator

If the task you are chaining to is the first task form in a process you might want to set the assignee as the ${initiator}. This process variable always holds the username of the person who started the process.

Assigning to Initiator

In this situation a user will submit a form, the process will start, and the user will immediately be presented with the task form for the first user task in the workflow.

_completed.user

When a user completes a task additional Standard Process Variables are generated. _TaskID_completed is a JavaScript object that holds information about the task that was just completed:

"_TaskID_completed": {
    "user": "<user who completed the task>",
    "proxyUser": "<user who completed using Assisted Service>",
    "taskId": "<task id in the process instance>",
    "time": "<time task was completed in ISO format>"
}

As this process variable includes the username of the user who completed the task, it could be used as the assignee of a subsequent task you'd like to chain to. In the example above, the task you'd like to chain to would have ${_TaskID_completed.user} as the assignee.

Note that the variable includes the ID of the task as part of its name. Task IDs are set in the modeller when you design your process. If the ID is left blank a random string will be used (for this reason it is always best to give your tasks proper, more human readable IDs).

The annotated example form related to this article uses the _completed variable and examines how to handle multiple paths of execution prior to the task you are chaining to, where you might not know the ID of the task and name of the variable.

Asynchronous Activities

Task chaining only works if none of the activities in between user tasks are asynchronous (see Workflow Transactions - Foreground and Background Jobs for more information about asynchronous tasks).

Additional Information

Task chaining is not a standard feature of BPMN process modelling, it's something we've implemented via the Workflow worker.

When the workflow engine queries the next task in a process it checks for the presence of a task variable called GOSS_AllowChaining. If this variable has the value true, chaining will take place, as described above. Note that this is a task variable, not a top-level process variable, so you won't ever see it when inspecting processes in the process modeller.

For more dynamic behaviour you could add this variable to a task using a task listener with an expression rather than a class.

This example has been added to a user task that may or may not be chained, depending on what was entered in the preceding task form. If a process variable called form_CHAINING has the value CHAIN, task chaining will be performed.

${form_CHAINING == "CHAIN" ? task.setVariableLocal("GOSS_AllowChaining", true) : task.setVariableLocal("GOSS_AllowChaining", false)}

Task Listener Expression

Last modified on June 19, 2019

Share this page

Facebook icon Twitter icon email icon

Print

print icon