processInstance.getVariables() unexpectedly returns an empty list

Hi,

I’ve created a ProcessInstance object using below code:

ProcessInstanceBuilder processInstanceBuilder = runtimeService.createProcessInstanceBuilder();
//add metadata as variables.
processInstanceBuilder.name(createProcessInstanceVO.getAppName());
processInstanceBuilder.processDefinitionKey(processDefinitionKey);
//TODO get rid of hardcoded strings.
processInstanceBuilder.variable("teamName", createProcessInstanceVO.getTeamName());
processInstanceBuilder.variable("serviceNowReference", createProcessInstanceVO.getServiceNowReference());
return processInstanceBuilder.start();

The returned object is of type ProcessInstance. When I debug my API, I can see that the object has a “variableInstances” object containing the “teamName” and “serviceNowReference”. So far, so good.

However, calling getVariables() on this returned object, results in an empty array.
I did not expect this and I am not sure how to retrieve the variables “teamName” and “serviceNowReference”

Am I conceptually missing something when it comes to creating and manipulating process instances?

edit: using flowable 6.0.0 and I’m excited to see that 6.0.1 is out already :slight_smile:

Regards,
Chris

1 Like

Hi Chris,

You are calling the getProcessVariables method right?
When you cast the result to an ExecutionEntity and call the getVariables method, you should get the variables you expect. We need to fix the getProcessVariables implementation so it returns this as well.

Best regards,

Tijs

1 Like

Hi Tijs,

This works like a charm!
Thank you very much!

Regards,
Chris

Thanks!. This helped me too! - I thought I was missing something blindingly obvious…