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.
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
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": {
"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
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
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
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 == "CHAIN" ? task.setVariableLocal("GOSS_AllowChaining", true) : task.setVariableLocal("GOSS_AllowChaining", false)}