cancel
Showing results for 
Search instead for 
Did you mean: 

Passing work items between service tasks

gouthr
Champ in-the-making
Champ in-the-making
Hi,

How does the Activiti engine pass the work items from one service task to the next? Let me explain with an example:

Say, I have a service task which invokes a java class. The java class does some processing and generates some values (work items). Now I need to be able to pass these work items to the next service task in the workflow - this in turn does some more processing on the received input and generates a new set of values (work items) which needs to be passed on to the next service task in the workflow chain. How do i do that?

Thanks!

3 REPLIES 3

gouthr
Champ in-the-making
Champ in-the-making
Similarly how do i read the input for the first service task? Currently I am running some sample JUNIT tests and I am hard-coding the input values. If I were to take the input from the user, how would I do it? Is it from a FormService?

gouthr
Champ in-the-making
Champ in-the-making
A follow up question. How can I use the default H2 database to (create a new table and )write and read new values from it? Any pointers to sample code or documentation would be great.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Goutham

1. Your custom logic implements JavaDelegate interface. Use execution to set variables (local or global) in the process instance

public class SetLocalVariableTask implements JavaDelegate {

public void execute(DelegateExecution execution) throws Exception {
   execution.setVariableLocal("testLocal", "test2");
    execution.setVariable("test", "test2");
  }

}

2. Read variable from execution.

3. Use DbSession or activiti queries.

Regards
Martin