Groovy script using class

Hi,

I am facing the following problem:

I have two executable BPMN workflows:

  • The first one is the “main” workflow
  • The second one is an activity call “sub” workflow what is called inside the “main” workflow.

The activity call properties are:
General:

  • Business key: checked
  • CallActivity Type: BPMN
  • Called Element: set
    Variables:
  • Both In and Out mapping: added Type variable mapping (all)
  • Local: unchecked

In the “sub” workflow I created a Script task which implements a Groovy script which contains the following implementation:

public class Abc implements Serializable {

String name;
Boolean result;
Integer score;

public Abc(String name, Boolean result, Integer score){
    this.name = name;
    this.result = result;
    this.score = score;
}

}
List abcs= new LinkedList<>();
def item = new Abc(“name”,true,10);
abcs.add(item);
execution.setVariable(“abcs”, abcs);
execution.setVariable(“apple”, “a”);

After in the “sub” workflow I put an end event where I added a listener which prints the abcs variable.
When I test it, it is printing fine. It contains the Abc object. [Abc@3e15101d]

After in the “main” workflow I put and end event where I added a listener which prints the abcs variable.
When I test it, it is printing fine. It contains the Abc object. [Abc@3e15101d]

But when the workflow run finished, right after I try to get back the history variables of this instance but the abcs variable is null! Other text based variables like “apple” works fine.

It looks like the class contained variable not persisted into the Camunda database.
I attached the related BPMNs.

sub.bpmn (3.5 KB)
main.bpmn (3.3 KB)

Thank you.
Best regards,
Rómeó Nagy