IHarris
IHarris

Reputation: 1

BPMN Diagram with 3-output Exclusive Gateway not working in Camunda

I'm working on a BPMN diagram contained within a .war file that's being deployed to Camunda. The diagram is showing up fine and I can complete the first two user tasks, but when I get to the exclusive gateway I'm getting the error message: Unknown property used in expression: ${Approve == 1}. Cause: Cannot resolve identifier 'Approve'

I haven't identified a variable Approve, but I'm not sure where to do this? I've been working with the .xml file for the BPMN diagram, in which the code relating to the exclusive gateway is as follows:

<bpmn:sequenceFlow id="SequenceFlow_07b7fwg" name="Approve" sourceRef="ExclusiveGateway_0znxqqy" targetRef="ServiceTask_06fn5cm">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${Approve == 1}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="SequenceFlow_0qnqvj1" sourceRef="ServiceTask_06fn5cm" targetRef="EndEvent_146k48m" />
    <bpmn:endEvent id="EndEvent_0ug591n" name="End">
      <bpmn:incoming>SequenceFlow_1y6i7xo</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_068nx8b" name="Reject" sourceRef="ExclusiveGateway_0znxqqy" targetRef="ServiceTask_17qnuyi">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${Reject == 2}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="SequenceFlow_1irpvhx" sourceRef="ServiceTask_17qnuyi" targetRef="ServiceTask_1jks4hs" />
    <bpmn:sequenceFlow id="SequenceFlow_1mjdjw2" sourceRef="ServiceTask_1jks4hs" targetRef="EndEvent_1qmduq" />
    <bpmn:endEvent id="EndEvent_1qmduq" name="Hello!" />
    <bpmn:sequenceFlow id="SequenceFlow_1deve3u" name="Extra Step" sourceRef="ExclusiveGateway_0znxqqy" targetRef="ServiceTask_09nq79v" />
    <bpmn:sequenceFlow id="SequenceFlow_1y6i7xo" sourceRef="ServiceTask_09nq79v" targetRef="EndEvent_0ug591n" />

This was based on the code provided by Camunda here: https://docs.camunda.org/manual/7.4/reference/bpmn20/gateways/exclusive-gateway/

There's also some .java files for each step which have been created within Eclipse, and refer to the same BPMN diagram. I'm not sure if the variables should be defined in the .xml file or the .java files, and how to go about doing this? Thanks.

Upvotes: 0

Views: 1079

Answers (1)

Zelldon
Zelldon

Reputation: 5516

You have two sequence flows which have conditional expressions. The expression reference on a variable named Approve respectively Reject. These variable must be defined in the current scope to be evaluated. There are different ways to create a variable, which should be evaluated afterwards. For example create a form on which you complete the user task and create the variable.

You can use the task complete REST resource to complete the user task and create variables.

Also it is possible to use the Java API inside an execution listener:

public class ExampleExecutionListenerOne implements ExecutionListener {

  public void notify(DelegateExecution execution) throws Exception {
    execution.setVariable("Approve", true);
  }
}

Hope it helps.

Upvotes: 3

Related Questions