Condition Expression of exclusive gateway

Hello everyone,

I wonder if it’s possible to write conditional expression using variable in camunda modeler, i mean , is it possible on a SequenceFlow to write a condition expression like ${transitionVariable == name of sequence flow}.

I know it is possible with java using this code :

ModelInstance modelInstance = sequenceFlow.getModelInstane();
ConditionExpression conditionExpression = modelInstance.newInstance(ConditionExpression.class);
conditionExpression.setTextContent("${transitionVariable == " + sequenceFlow.getName() + “}”);

But i don’t know how to update the bpmn process definition after that ???

Can someone help me on this issue ? Thanks.

How are you getting the “sequenceFlow” variable in the first place? You likely can do the same access and the method getName using an expression

Hello, thanks for your reply .

To get the sequenceFlow i’m doing the following :

ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();

BpmnModelInstance bpmnModelInstance = repositoryService.getBpmnModelInstance(processInstance.getProcessDefinitionId());

FlowNode flowNode = (FlowNode) bpmnModelInstance.getModelElementById(taskKey);

for(SequenceFlow sequenceFlow : node.getOutgoing()){
** /// Here is my sequence flow**

But in Camunda Modeler :


I don’t know how to access the variable sequenceFlow.


You would likely have to create a bean method that can run your logic and then call it as a expression. Any reason why you want to base your logic on the Id of the sequence flow? It would be likely much easier to do this as expected values: where each expression in the sequence flow is set to something like “${myVar == cat}”. Where cat is the different sequence flows expressions. It is essentially the same config setup as using the ID, but you don’t need to do all the DB and XML look ups.

Ok very nice. Thanks for the quick answer , it will do the trick for me . :slight_smile: