Camunda Expression - Access field of object variable

Hello,
I’m using Camunda 7.16 integrated with Springboot.

Question: Is there a way I can access a property of an object which is stored as a Camunda Variable, directly from a Camunda expression in bpmn?

In java, I have the following object:

public class Stage {
    private String name;
    private String level;

    // getters & setters
}

I have stored an instance of that object as a Camunda variable called “stage”.
I want to directly access the property “name” of that camunda variable through a camunda expression.

For example, I have tried the following:
${execution.getVariable(“stage.name”)}
${execution.getVariable(“stage.getName()”)}

but unfortunately none of them works.

Any ideas?

Thanks,
Nick

Ok, I found the solution. Posting it in case someone is interested:

${execution.getVariable("stage").getName()}
or even
${stage.getName()}

Just a word of warning on this.
All Camunda locations that will use that code will need to have access to the JAR that contains the getters for that object type.

It might be worthwhile storing it in the variable as a JSON object rather than a native POJO.

3 Likes