Possible to add "static attributes" to tasks and read them from DB or via RuntimeService?

Hi All

What I want to achieve is to somehow store “static” key value pairs in tasks. I then want to be able to get those values from within the Javacode (preferably using the processInstanceId). The goal is to be able to easily change some values in Camunda Modeler which influences for example in which page the task is displayed without having to hardcode Task X goes into page1, Task Y into page2, etc.

I thought I could maybe do this using the camunda:inputOutput > camunda:inputParameter. But as those are inside bpmn:extensionElements. And as far as I understand, I would have to get the bytes of the XML from the ACT_GE_BYTEARRAY table, parse the XML and get the values. I don’t want to do something like that.

I found in the Rest API the following: GET /execution/{id}/localVariables I think I would need something like that but without Rest.

TL;DR: Is it possible to set (in the Modeler) “constants” or lets say task attributes and read them from either the RuntimeService or from the Database?

@chiffshinz can you just use execution.getVariableLocal('myVarName') in your java code?

https://docs.camunda.org/javadoc/camunda-bpm-platform/7.8/org/camunda/bpm/engine/delegate/VariableScope.html#getVariableLocal(java.lang.String)

1 Like

Hi, thanks for your response.
I just tried it and I am able to get variables out which were set from Java code. They were set with RuntimeService.setVariable(String executionId, String variableName, Object value)
But somehow the variables which are set in the xml with camunda:inputParameter don’t seem to be accessible with this method. I printed every Task and their variables which I got with RuntimeService.getVariablesLocal(String executionId).

This is the bpmn:

<bpmn:extensionElements>
    <camunda:inputOutput>
        <camunda:inputParameter name="task_list_table">correct</camunda:inputParameter>
        <camunda:inputParameter name="task_list_action">editForm</camunda:inputParameter>
    </camunda:inputOutput>
</bpmn:extensionElements>

So I just found that my variables are stored in the ACT_RU_VARIABLE table.
This solves the problem.

Thanks again for your response.