I have been playing a bit with processes and human tasks, and I want to show how we can share variables between human tasks in Jbpm5.
Let’s see the following process:

There are three human tasks which may have input/output:
- Write document: Should produce an output that should contain a document which will be used by the rest of the process.
- Translate Document: Should take the “Write document” output to show to the user for reference, and produce an output that will contain the translated document.
- Review Document: Should take the “Write document” output to show to the user for reference, and produce an output that will contain the review of this document.
First, let’s deal with the write document output.
In the .bpmn file, we will add a new item definition, which will define the structure and a name for this structure, and then declare a variable inside our process:
Ok, now we should define the variable inside the “Write document” task, and bind it with this process property:
– Results will be the name of the variable inside the task.
– In dataOutputAssociation we put the value of the Results to the approval.document variable.
Now, let’s use this variable as an input of “Translate Document”. We will use the already filled approval.document variable, and declare it as a parameter for the task.
Please note for the input variable, I used “Content” name variable. If you see the
workitem for human tasks in jbpm5, its takes some predefined parameters and sends them to the task server, so the input information should be put in Content input.
Edit: after a salaboy commit some time ago, now, the input of the task will be get from the “content” variable. If you want to send many separate variables, you can omit (send it blank) the content variable, and add other variables. If the human task work item handler does not find anything in content variable, it will send a map with all the task variables as input.
The complete process definition can be found here:
Now, how can I use it from my human task?
To get the input, using the TaskClient and having the TaskSummary is possible:
To send the output:
The full example can be found in my examples github repository:
That’s all for now. Hope it helps.
Thanks for reading!
Demian