How to access Task properties / Where are they stored?

Hi All,

I have specified some custom properties as part of an abstract task. I would like to report on these properties after the process has executed, but cannot find how to access properties - Any ideas ? Which REST Route or Table should be queried ?

e.g.

<task id="A6684C675475B" name="Abstract task">
  <extensionElements>
    <camunda:properties>
      <camunda:property name="Property1" value="5"/>
      <camunda:property name="Property2" value="2"/>
    </camunda:properties>
  </extensionElements>
  <incoming>AEECC20ED594347</incoming>
  <outgoing>D54ABA602A141A6</outgoing>
</task>

I am using Camunda 7.2, and this post ( https://groups.google.com/forum/#!searchin/camunda-bpm-users/extension$20element|sort:relevance/camunda-bpm-users/lIGFLIBHpwA/LdSaYBDqvYMJ ) indicates that properties are not accessible via the API, however, they must be in the database somewhere ???

Thanks in advance,

Gareth

Hi Gareth,

They are indeed in the database but not as first class citizens. The properties are part of the XML and the XML is persisted in the database. In Java, you can access the model via BpmnModelInstance model = runtimeService.getBpmnModelInstance(processDefinitionId); and then continue with the code of the answer in the post you linked.

If you are using the REST API, you can retrieve the XML via GET /process-definition/{id}/xml, see the REST API docs, and then parse it from there. Iā€™m not familiar with the bpmn.io toolkits, but they might have something that helps you with that task in Javascript, similar to the model API in Java.

Cheers,
Thorben

Thanks Thorben,

Do you know which table the XML gets stored in ? ( Im trying to run a SQL report - maybe act_ge_bytearray ? )

Can you recommend any other way to inject custom variables at an activity level ?

Hi Gareth,

ACT_GE_BYTEARRAY is correct. For correctly interpreting the BYTES_ field, your report script must be able to detect the encoding from the XML declaration or assume one (should be UTF-8).

Depending on what you want to do, you can use input/output mappings. These are converted to variables at runtime when an activity is executed.

Cheers,
Thorben

Thanks Thorben.

I am trying to attribute some values against tasks which can later be reported on. E.g. If the task is a service, then attribute a numerical cost ( or saving ) for using this service, and be able to compute an overall cost for a particular process.

I think Input/Output mappings will create a process level variable, so wouldnt work - but ill check the docs / try it to make sure. Parsing the XML in SQL is a bit nasty so I really dont want to go down that road.

Does the REST API now provides the task extensions - the original post is somehow quite old?

1 Like

It would be extremely useful to have this attributes accessible via API by accessing the task itself

for example, adding custom configs for tasks
you want them related to your process definition,
if I need to move them to input variables for example I would have stored them for each instance, making all data unnecessary duplicated many many times

what we probably will do then is cache the XML and use it to find this information :frowning:

+1 from me
It would be very useful to be able to define a custom attribute and be able to read it through the REST API