2

I have several processes in my camunda process model. I want to sort them after a numerical order, therefore I added a variable in each process which I called "process_order" and giving them a number which represents the order (1 is the first priority, 2 is second priority etc.) as shown in the picture below.

process_order in extension property on the whole process

In the BPMN file it looks like this:

bpmn file

So I'm wondering how to get the extension property out using Java?

Thanks for any reply :)

Sandeep Kumar
  • 2,397
  • 5
  • 30
  • 37
tsr95
  • 21
  • 1
  • 4
  • [How to read and write xml files?](https://stackoverflow.com/questions/7373567/how-to-read-and-write-xml-files) – Adder Dec 16 '19 at 10:00
  • Refer :https://forum.camunda.org/t/how-do-i-read-model-camunda-property-in-a-java-delegate-execution-listener/6080 – TechFree Dec 16 '19 at 13:08

2 Answers2

2

When / from where would you like to read the property?

Does the model API doc here answer your question? https://docs.camunda.org/manual/latest/user-guide/model-api/bpmn-model-api/extension-elements/

If you need to read the information from an execution:

ServiceTask serviceTask = (ServiceTask) execution.getBpmnModelElementInstance();

CamundaProperties camProperties = serviceTask.getExtensionElements().getElementsQuery().filterByType(CamundaProperties.class).singleResult(); 

    for (CamundaProperty camProperty : camProperties.getCamundaProperties()) 
        {
          String name = camProperty.getCamundaName();
          String value = camProperty.getCamundaValue();
        }
rob2universe
  • 7,059
  • 39
  • 54
-1

Add a java class as a listener as shown in below image.

Java class should implement the org.camunda.bpm.engine.delegate.JavaDelegate.

In the overriden method,you can get the variable by

execution.getVariable("variable-name")

Camunda Process Listener Image

Maaz
  • 21
  • 3