Conditional Event not triggered when variable updated

Hi.

I have a process where I am trying to trigger a non-interrupting conditional event based on a variable update that happens when a task is assigned based on a task listener event. I can see my variable update happening when the task is claimed/assigned, however the conditional event does not trigger.

Any help would be appreciated.

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_12xfefb" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.12.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
  <bpmn:process id="taskListenerExample" name="Task Listener Payment Example" isExecutable="true">
    <bpmn:businessRuleTask id="DisplayFormReviewPaymentRequest" name="Review Payment Request" camunda:resultVariable="approvedResult" camunda:decisionRef="approvePayment" camunda:mapDecisionResult="singleResult">
      <bpmn:incoming>ToPaymentReview</bpmn:incoming>
      <bpmn:outgoing>ToPaymentApprovedCheck</bpmn:outgoing>
    </bpmn:businessRuleTask>
    <bpmn:userTask id="DisplayFormToRequestPayment" name="Request Payment">
      <bpmn:extensionElements>
        <camunda:formData>
          <camunda:formField id="amount" label="Payment Amount" type="long" />
          <camunda:formField id="clientType" label="Client Type" type="enum">
            <camunda:value id="VIP" name="VIP" />
            <camunda:value id="NONVIP" name="NONVIP" />
          </camunda:formField>
        </camunda:formData>
        <camunda:properties>
          <camunda:property name="overrideAsyncBefore" value="true" />
        </camunda:properties>
        <camunda:taskListener event="assignment" id="taskAssignmentListener">
          <camunda:script scriptFormat="javascript">task.setVariable('taskAssigned',"yes");</camunda:script>
        </camunda:taskListener>
        <camunda:inputOutput>
          <camunda:inputParameter name="taskAssigned">no</camunda:inputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>ToRequestPayment</bpmn:incoming>
      <bpmn:outgoing>Flow_1uzm03f</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:exclusiveGateway id="Gateway_1085co1">
      <bpmn:incoming>ToChargeCreditCard</bpmn:incoming>
      <bpmn:incoming>ToChargeCreditCardFromPaymentApprovedCheck</bpmn:incoming>
      <bpmn:outgoing>Flow_0jneq5k</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:exclusiveGateway id="ExclusiveGateway_0zpj68m" name="Payment Approved?">
      <bpmn:incoming>ToPaymentApprovedCheck</bpmn:incoming>
      <bpmn:outgoing>ToChargeCreditCardFromPaymentApprovedCheck</bpmn:outgoing>
      <bpmn:outgoing>ToSendDeclineMessage</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:startEvent id="InitiatePaymentStartEvent" name="Initiate Payment">
      <bpmn:outgoing>ToRequestPayment</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:endEvent id="Event_0avm8rl" name="Send Successful Message">
      <bpmn:incoming>ToSendSuccessfulMessage</bpmn:incoming>
      <bpmn:messageEventDefinition id="MessageEventDefinition_1lfc48r" camunda:type="external" camunda:topic="send-success" />
    </bpmn:endEvent>
    <bpmn:serviceTask id="CargeCreditCard" name="Charge Credit Card" camunda:asyncBefore="true" camunda:delegateExpression="${chargeCreditCardService}">
      <bpmn:incoming>Flow_0jneq5k</bpmn:incoming>
      <bpmn:outgoing>ToSendSuccessfulMessage</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:endEvent id="DeclineEnd" name="Send Decline Message">
      <bpmn:incoming>ToSendDeclineMessage</bpmn:incoming>
      <bpmn:messageEventDefinition id="MessageEventDefinition_1u5xztk" camunda:class="za.co.fnb.demo.camunda.service.SendDeclineEmail" />
    </bpmn:endEvent>
    <bpmn:endEvent id="Event_0g2g41g" name="Send Error Message">
      <bpmn:incoming>ToSendErroMessage</bpmn:incoming>
      <bpmn:messageEventDefinition id="MessageEventDefinition_1xu9ie0" camunda:type="external" camunda:topic="send-error" />
    </bpmn:endEvent>
    <bpmn:exclusiveGateway id="ExclusiveGateway_0ejfnjx" name="Payment Amount?">
      <bpmn:incoming>Flow_1uzm03f</bpmn:incoming>
      <bpmn:outgoing>ToPaymentReview</bpmn:outgoing>
      <bpmn:outgoing>ToChargeCreditCard</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:boundaryEvent id="ServiceError" name="Handle Service Error" attachedToRef="CargeCreditCard">
      <bpmn:outgoing>ToSendErroMessage</bpmn:outgoing>
      <bpmn:errorEventDefinition id="ErrorEventDefinition_08vbu8a" />
    </bpmn:boundaryEvent>
    <bpmn:sequenceFlow id="ToPaymentReview" name="&#62;= R10 000" sourceRef="ExclusiveGateway_0ejfnjx" targetRef="DisplayFormReviewPaymentRequest">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${amount&gt;=10000}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="ToPaymentApprovedCheck" sourceRef="DisplayFormReviewPaymentRequest" targetRef="ExclusiveGateway_0zpj68m" />
    <bpmn:sequenceFlow id="ToRequestPayment" sourceRef="InitiatePaymentStartEvent" targetRef="DisplayFormToRequestPayment" />
    <bpmn:sequenceFlow id="ToChargeCreditCard" name="&#60; R10 000" sourceRef="ExclusiveGateway_0ejfnjx" targetRef="Gateway_1085co1">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${amount &lt; 10000}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="ToChargeCreditCardFromPaymentApprovedCheck" name="Yes" sourceRef="ExclusiveGateway_0zpj68m" targetRef="Gateway_1085co1">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${approvedResult.approved == 'True'}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_0jneq5k" sourceRef="Gateway_1085co1" targetRef="CargeCreditCard" />
    <bpmn:sequenceFlow id="ToSendDeclineMessage" name="No" sourceRef="ExclusiveGateway_0zpj68m" targetRef="DeclineEnd">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${approvedResult.approved == 'False'}</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="ToSendSuccessfulMessage" sourceRef="CargeCreditCard" targetRef="Event_0avm8rl" />
    <bpmn:sequenceFlow id="ToSendErroMessage" sourceRef="ServiceError" targetRef="Event_0g2g41g" />
    <bpmn:serviceTask id="taskAssignedService" name="Task assigned service" camunda:asyncBefore="true" camunda:expression="${taskAssignedService}">
      <bpmn:incoming>Flow_11kz959</bpmn:incoming>
      <bpmn:outgoing>Flow_1shd8df</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_1uzm03f" sourceRef="DisplayFormToRequestPayment" targetRef="ExclusiveGateway_0ejfnjx" />
    <bpmn:boundaryEvent id="Event_07ab2yp" attachedToRef="taskAssignedService">
      <bpmn:outgoing>Flow_0hlxudn</bpmn:outgoing>
      <bpmn:errorEventDefinition id="ErrorEventDefinition_04qow1r" />
    </bpmn:boundaryEvent>
    <bpmn:endEvent id="Event_0fg03wp">
      <bpmn:incoming>Flow_1shd8df</bpmn:incoming>
      <bpmn:incoming>Flow_0hlxudn</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_1shd8df" sourceRef="taskAssignedService" targetRef="Event_0fg03wp" />
    <bpmn:sequenceFlow id="Flow_0hlxudn" sourceRef="Event_07ab2yp" targetRef="Event_0fg03wp" />
    <bpmn:boundaryEvent id="NonInterruptingCondition" cancelActivity="false" attachedToRef="DisplayFormToRequestPayment">
      <bpmn:outgoing>Flow_11kz959</bpmn:outgoing>
      <bpmn:conditionalEventDefinition id="ConditionalEventDefinition_0n6f7vi" camunda:variableName="taskAssigned" camunda:variableEvents="update">
        <bpmn:condition xsi:type="bpmn:tFormalExpression">${taskAssigned == 'yes'}</bpmn:condition>
      </bpmn:conditionalEventDefinition>
    </bpmn:boundaryEvent>
    <bpmn:sequenceFlow id="Flow_11kz959" sourceRef="NonInterruptingCondition" targetRef="taskAssignedService" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="taskListenerExample">
      <bpmndi:BPMNEdge id="Flow_0hlxudn_di" bpmnElement="Flow_0hlxudn">
        <di:waypoint x="400" y="508" />
        <di:waypoint x="400" y="528" />
        <di:waypoint x="545" y="528" />
        <di:waypoint x="545" y="468" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1shd8df_di" bpmnElement="Flow_1shd8df">
        <di:waypoint x="450" y="450" />
        <di:waypoint x="527" y="450" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1uzm03f_di" bpmnElement="Flow_1uzm03f">
        <di:waypoint x="450" y="299" />
        <di:waypoint x="520" y="299" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="ToSendErroMessage_di" bpmnElement="ToSendErroMessage">
        <di:waypoint x="830" y="357" />
        <di:waypoint x="830" y="410" />
        <di:waypoint x="920" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="ToSendSuccessfulMessage_di" bpmnElement="ToSendSuccessfulMessage">
        <di:waypoint x="870" y="299" />
        <di:waypoint x="922" y="299" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="ToSendDeclineMessage_di" bpmnElement="ToSendDeclineMessage">
        <di:waypoint x="715" y="150" />
        <di:waypoint x="922" y="150" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="747" y="132" width="15" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0jneq5k_di" bpmnElement="Flow_0jneq5k">
        <di:waypoint x="715" y="299" />
        <di:waypoint x="770" y="299" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="ToChargeCreditCardFromPaymentApprovedCheck_di" bpmnElement="ToChargeCreditCardFromPaymentApprovedCheck">
        <di:waypoint x="690" y="175" />
        <di:waypoint x="690" y="274" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="666" y="188" width="18" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="ToChargeCreditCard_di" bpmnElement="ToChargeCreditCard">
        <di:waypoint x="570" y="299" />
        <di:waypoint x="665" y="299" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="579" y="282" width="52" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="ToRequestPayment_di" bpmnElement="ToRequestPayment">
        <di:waypoint x="218" y="299" />
        <di:waypoint x="350" y="299" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="ToPaymentApprovedCheck_di" bpmnElement="ToPaymentApprovedCheck">
        <di:waypoint x="595" y="150" />
        <di:waypoint x="665" y="150" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="ToPaymentReview_di" bpmnElement="ToPaymentReview">
        <di:waypoint x="545" y="274" />
        <di:waypoint x="545" y="190" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="551" y="233" width="58" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_11kz959_di" bpmnElement="Flow_11kz959">
        <di:waypoint x="400" y="357" />
        <di:waypoint x="400" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="DisplayFormReviewPaymentRequest_di" bpmnElement="DisplayFormReviewPaymentRequest">
        <dc:Bounds x="495" y="110" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="DisplayFormToRequestPayment_di" bpmnElement="DisplayFormToRequestPayment">
        <dc:Bounds x="350" y="259" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_1085co1_di" bpmnElement="Gateway_1085co1" isMarkerVisible="true">
        <dc:Bounds x="665" y="274" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ExclusiveGateway_0zpj68m_di" bpmnElement="ExclusiveGateway_0zpj68m" isMarkerVisible="true">
        <dc:Bounds x="665" y="125" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="663" y="86" width="53" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0avm8rl_di" bpmnElement="Event_0avm8rl">
        <dc:Bounds x="922" y="281" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="969" y="285" width="83" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="CargeCreditCard_di" bpmnElement="CargeCreditCard">
        <dc:Bounds x="770" y="259" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="DeclineEnd_di" bpmnElement="DeclineEnd">
        <dc:Bounds x="922" y="132" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="967" y="136" width="66" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0g2g41g_di" bpmnElement="Event_0g2g41g">
        <dc:Bounds x="922" y="392" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="962" y="396" width="55" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ExclusiveGateway_0ejfnjx_di" bpmnElement="ExclusiveGateway_0ejfnjx" isMarkerVisible="true">
        <dc:Bounds x="520" y="274" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="522" y="334" width="45" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_022q0pt_di" bpmnElement="taskAssignedService">
        <dc:Bounds x="350" y="410" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0fg03wp_di" bpmnElement="Event_0fg03wp">
        <dc:Bounds x="527" y="432" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="InitiatePaymentStartEvent_di" bpmnElement="InitiatePaymentStartEvent">
        <dc:Bounds x="182" y="281" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="160" y="327" width="80" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0djl6fe_di" bpmnElement="Event_07ab2yp">
        <dc:Bounds x="382" y="472" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ServiceError_di" bpmnElement="ServiceError">
        <dc:Bounds x="812" y="321" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="742" y="345" width="75" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0mdscz0_di" bpmnElement="NonInterruptingCondition">
        <dc:Bounds x="382" y="321" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Thanks

It’s probably related to the variable assignment happening on the task (task.setVariable) rather than on the process.

Try setting the variable with execution.setVariable instead and see if that works.

Thanks for your response. I don’t think execution is in scope in the task listener. I have tried this and can see the error beloe:

org.camunda.bpm.engine.ProcessEngineException: ENGINE-03051 There was an exception while invoking the TaskListener. Message: 'Unable to evaluate script while executing activity 'DisplayFormToRequestPayment' in the process definition with id 'taskListenerExample:1:3d3ef4d3-c008-11ec-8a4a-5414f31819ac':ReferenceError: "execution" is not defined in <eval> at line number 1'
	at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.invokeTaskListenerException(EnginePersistenceLogger.java:451) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.persistence.entity.TaskEntity.invokeListener(TaskEntity.java:1085) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:1030) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.persistence.entity.TaskEntity.fireAssignmentEvent(TaskEntity.java:1215) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.persistence.entity.TaskEntity.triggerUpdateEvent(TaskEntity.java:1190) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.cmd.ClaimTaskCmd.execute(ClaimTaskCmd.java:70) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.cmd.ClaimTaskCmd.execute(ClaimTaskCmd.java:35) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:110) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:72) [camunda-engine-spring-7.16.0.jar:7.16.0]
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) [spring-tx-5.3.9.jar:5.3.9]
	at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:70) [camunda-engine-spring-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70) [camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.interceptor.CommandCounterInterceptor.execute(CommandCounterInterceptor.java:35) [camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33) [camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.TaskServiceImpl.claim(TaskServiceImpl.java:171) [camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.rest.sub.task.impl.TaskResourceImpl.claim(TaskResourceImpl.java:93) [camunda-engine-rest-jaxrs2-7.16.0.jar:7.16.0]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_321]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_321]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_321]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_321]
	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) [jersey-server-2.33.jar:na]
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124) ~[jersey-server-2.33.jar:na]
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167) ~[jersey-server-2.33.jar:na]
	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:159) ~[jersey-server-2.33.jar:na]
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79) ~[jersey-server-2.33.jar:na]
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:475) ~[jersey-server-2.33.jar:na]
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:397) ~[jersey-server-2.33.jar:na]
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81) ~[jersey-server-2.33.jar:na]
	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255) ~[jersey-server-2.33.jar:na]
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) ~[jersey-common-2.33.jar:na]
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) ~[jersey-common-2.33.jar:na]
	at org.glassfish.jersey.internal.Errors.process(Errors.java:292) ~[jersey-common-2.33.jar:na]
	at org.glassfish.jersey.internal.Errors.process(Errors.java:274) ~[jersey-common-2.33.jar:na]
	at org.glassfish.jersey.internal.Errors.process(Errors.java:244) ~[jersey-common-2.33.jar:na]
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265) ~[jersey-common-2.33.jar:na]
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234) ~[jersey-server-2.33.jar:na]
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680) ~[jersey-server-2.33.jar:na]
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394) ~[jersey-container-servlet-core-2.33.jar:na]
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346) ~[jersey-container-servlet-core-2.33.jar:na]
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366) ~[jersey-container-servlet-core-2.33.jar:na]
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319) ~[jersey-container-servlet-core-2.33.jar:na]
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205) ~[jersey-container-servlet-core-2.33.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:228) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.camunda.bpm.engine.rest.filter.CacheControlFilter.doFilter(CacheControlFilter.java:45) ~[camunda-engine-rest-jaxrs2-7.16.0.jar:7.16.0]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.camunda.bpm.engine.rest.filter.EmptyBodyFilter.doFilter(EmptyBodyFilter.java:99) ~[camunda-engine-rest-jaxrs2-7.16.0.jar:7.16.0]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.camunda.bpm.webapp.impl.engine.ProcessEnginesFilter.applyFilter(ProcessEnginesFilter.java:145) ~[camunda-webapp-7.16.0-classes.jar:7.16.0]
	at org.camunda.bpm.webapp.impl.filter.AbstractTemplateFilter.doFilter(AbstractTemplateFilter.java:58) ~[camunda-webapp-7.16.0-classes.jar:7.16.0]
	at org.camunda.bpm.spring.boot.starter.webapp.filter.LazyDelegateFilter.doFilter(LazyDelegateFilter.java:60) ~[camunda-bpm-spring-boot-starter-webapp-core-7.16.0.jar:7.16.0]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.camunda.bpm.webapp.impl.security.filter.headersec.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:89) ~[camunda-webapp-7.16.0-classes.jar:7.16.0]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.camunda.bpm.webapp.impl.security.filter.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:177) ~[camunda-webapp-7.16.0-classes.jar:7.16.0]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.camunda.bpm.webapp.impl.security.filter.SecurityFilter.doFilterSecure(SecurityFilter.java:73) ~[camunda-webapp-7.16.0-classes.jar:7.16.0]
	at org.camunda.bpm.webapp.impl.security.filter.SecurityFilter.doFilter(SecurityFilter.java:57) ~[camunda-webapp-7.16.0-classes.jar:7.16.0]
	at org.camunda.bpm.spring.boot.starter.webapp.filter.LazyDelegateFilter.doFilter(LazyDelegateFilter.java:60) ~[camunda-bpm-spring-boot-starter-webapp-core-7.16.0.jar:7.16.0]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter$1.execute(AuthenticationFilter.java:62) ~[camunda-webapp-7.16.0-classes.jar:7.16.0]
	at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter$1.execute(AuthenticationFilter.java:60) ~[camunda-webapp-7.16.0-classes.jar:7.16.0]
	at org.camunda.bpm.webapp.impl.security.SecurityActions.runWithAuthentications(SecurityActions.java:44) ~[camunda-webapp-7.16.0-classes.jar:7.16.0]
	at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:60) ~[camunda-webapp-7.16.0-classes.jar:7.16.0]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.9.jar:5.3.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.9.jar:5.3.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.9.jar:5.3.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1723) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_321]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_321]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
	at java.lang.Thread.run(Thread.java:750) ~[na:1.8.0_321]
Caused by: org.camunda.bpm.engine.ScriptEvaluationException: Unable to evaluate script while executing activity 'DisplayFormToRequestPayment' in the process definition with id 'taskListenerExample:1:3d3ef4d3-c008-11ec-8a4a-5414f31819ac':ReferenceError: "execution" is not defined in <eval> at line number 1
	at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluate(SourceExecutableScript.java:71) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.scripting.ExecutableScript.execute(ExecutableScript.java:63) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:99) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:87) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.delegate.ScriptInvocation.invoke(ScriptInvocation.java:47) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:58) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:92) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:63) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener.notify(ScriptTaskListener.java:45) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation.invoke(TaskListenerInvocation.java:45) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:58) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:92) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:63) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor$1.call(DefaultDelegateInterceptor.java:57) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor$1.call(DefaultDelegateInterceptor.java:54) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.context.ProcessApplicationClassloaderInterceptor.call(ProcessApplicationClassloaderInterceptor.java:48) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.application.AbstractProcessApplication.execute(AbstractProcessApplication.java:131) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.application.AbstractProcessApplication.execute(AbstractProcessApplication.java:142) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.context.Context.executeWithinProcessApplication(Context.java:206) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:54) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.persistence.entity.TaskEntity.invokeListener(TaskEntity.java:1099) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.persistence.entity.TaskEntity.invokeListener(TaskEntity.java:1079) ~[camunda-engine-7.16.0.jar:7.16.0]
	... 102 common frames omitted
Caused by: javax.script.ScriptException: ReferenceError: "execution" is not defined in <eval> at line number 1
	at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470) ~[nashorn.jar:na]
	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:454) ~[nashorn.jar:na]
	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406) ~[nashorn.jar:na]
	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402) ~[nashorn.jar:na]
	at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155) ~[nashorn.jar:na]
	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233) ~[na:1.8.0_321]
	at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluateScript(SourceExecutableScript.java:125) ~[camunda-engine-7.16.0.jar:7.16.0]
	at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluate(SourceExecutableScript.java:65) ~[camunda-engine-7.16.0.jar:7.16.0]
	... 123 common frames omitted
Caused by: jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "execution" is not defined
	at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57) ~[nashorn.jar:na]
	at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319) ~[nashorn.jar:na]
	at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291) ~[nashorn.jar:na]
	at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1442) ~[nashorn.jar:na]
	at jdk.nashorn.internal.scripts.Script$\^eval\_.:program(<eval>:1) ~[na:na]
	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637) ~[nashorn.jar:na]
	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) ~[nashorn.jar:na]
	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) ~[nashorn.jar:na]
	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449) ~[nashorn.jar:na]
	... 129 common frames omitted```

Yes, you are correct.

According to Unable to use execution.setVariable() in listener inline script - #2 by hassang

You’ll want to use task.execution.setVariable

Thanks. Did not know that I could do that.

I have tried that now, however the conditional boundary event still does not get triggered.

I think you need input from someone who knows more about the internals than I do.
The way you’re set up now sounds like it should work to me, but I obviously missed something.

Appreciate the attempt though. Please could you share of you have any camunda process that successfully can trigger a conditional event

Hi @Zishaan,

taskAssigned is defined as input parameter to the user task which means it is defined in the scope of the user task’s activity.

Please try removing the input parameter taskAssigned and ensure it is created as process instance variable.

Hi @hassang

Thank you for your response. I have tried this as well where the variable is created when the javascript piece of code in the task listener executes. i.e:

task.execution.setVariable('taskAssigned',"yes");

If that is not what you mean could you kindly explain further where I could create the variable ? I have also tried having a script task before the user task that creates the variable so it is in the process scope.

Thanks
Zishaan

I wonder if anyone has an existing process that triggers a conditional event the way I am trying to ? I have struggled to find one that is not just theoretical and that actually has a bpmn process modelled in camunda modeler that can trigger a boundary/intermediate catch conditional event

Hi @Zishaan,

It looks like setting the variable through a task listener (tested on assignment event) doesn’t trigger the attached conditional event for some reason.

I did a small test setting the variable using an execution listener (tested on start event) and the attached conditional event has been triggered as expected.

1 Like

Hi @Zishaan,

to confirm @hassang’s observation I had a quick look into the JUnit tests for the conditional event here: camunda-bpm-platform/engine/src/test/java/org/camunda/bpm/engine/test/bpmn/event/conditional at master · camunda/camunda-bpm-platform · GitHub

There is a test class ConditionalEventTriggeredByExecutionListenerTest But nothing with a Task listener in the name. Seems to be a missing implementation.

If you like, you can contribute with a test and the missing implementation.

Hope this helps, Ingo

2 Likes

I’ve found a different approach to make this work.
Using a message boundary event and a correlation by script on assignment, using the fluent API for message correlation by the runtimeService, as shown here.

The script on this BPMN user task (Task #1) is triggering only when a user claims the task. If you wish to correlate the message when the assigned user is removed as well, just remove the if statement from the script.

Boundary Event Trigger on Task Assignment.bpmn (4.4 KB)

Hope this helps :slight_smile:

Hi @GabrielCasaro,

Thanks for sharing your solution

Hi Hassang,
I tested this as well and the issue seems to be with the variable value getting persisted when using task listener.
Two things I tried
1.Updated the variable back and forth to the conditional value in cockpit and then you will see the conditional event executing.
2.Use an event sub process with non-interrupting start event and update the variable matching the condition. Even then the conditional event will execute.