softcannery / camunda-formio-accelerator

Camunda Platform Accelerator for Form.io
https://www.softcannery.com/camunda-platform-acc-for-formio
Other
5 stars 3 forks source link

Start or End Event Listener on the Start Event seems to break the Accelerator #48

Open proth1 opened 11 months ago

proth1 commented 11 months ago

The submission data does not seem to end up in the accelerator's Camunda variable: formio.start.json variable.

The following Hello World.bpmn file is an example that will recreate the problem.

Start Event | Event Listener | javascript expression:

execution.setVariable("variableName", true);

Attached is the Hello World.formio file

Following is the Hello World BPMN XML that demonstrates the issue.

<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_05fei88" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.15.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
  <bpmn:process id="helloWorld" name="Hello World" isExecutable="true" camunda:historyTimeToLive="180">
    <bpmn:extensionElements>
      <camunda:properties>
        <camunda:property name="processType" value="Admin" />
      </camunda:properties>
    </bpmn:extensionElements>
    <bpmn:startEvent id="StartEvent_1" name="Start" camunda:formHandlerClass="org.softcannery.camunda.FormioStartFormHandler" camunda:formKey="embedded:app:formio.html">
      <bpmn:extensionElements>
        <camunda:properties>
          <camunda:property name="formio.variable" value="start" />
          <camunda:property name="formio.outputDataSource" value="start" />
          <camunda:property name="formio.file" value="Hello World.formio" />
          <camunda:property name="formio.form" value="case" />
        </camunda:properties>
        <camunda:executionListener event="start">
          <camunda:script scriptFormat="javascript">execution.setVariable("variableName", true);</camunda:script>
        </camunda:executionListener>
      </bpmn:extensionElements>
      <bpmn:outgoing>Flow_039ivcy</bpmn:outgoing>
      <bpmn:dataOutputAssociation id="DataOutputAssociation_1vlaqwe">
        <bpmn:targetRef>DataStoreReference_0gccua2</bpmn:targetRef>
      </bpmn:dataOutputAssociation>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_039ivcy" sourceRef="StartEvent_1" targetRef="Activity_1kueh7l" />
    <bpmn:dataStoreReference id="DataStoreReference_0gccua2" name="start" />
    <bpmn:userTask id="Activity_1kueh7l" name="Show start Data" camunda:formKey="embedded:app:formio.html" camunda:assignee="proth@velocityz.com">
      <bpmn:extensionElements>
        <camunda:properties>
          <camunda:property name="formio.variable" value="Activity_1kueh7l" />
          <camunda:property name="formio.inputDataSource" value="start" />
          <camunda:property name="formio.outputDataSource" value="start" />
          <camunda:property name="formio.file" value="Hello World.formio" />
          <camunda:property name="formio.form" value="case" />
        </camunda:properties>
        <camunda:inputOutput>
          <camunda:inputParameter name="Activity_1kueh7l">${formio.start.json}</camunda:inputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_039ivcy</bpmn:incoming>
      <bpmn:outgoing>Flow_0blo8ha</bpmn:outgoing>
      <bpmn:property id="Property_130sf3r" name="__targetRef_placeholder" />
      <bpmn:dataInputAssociation id="DataInputAssociation_18ys0mj">
        <bpmn:sourceRef>DataStoreReference_0gccua2</bpmn:sourceRef>
        <bpmn:targetRef>Property_130sf3r</bpmn:targetRef>
      </bpmn:dataInputAssociation>
      <bpmn:dataOutputAssociation id="DataOutputAssociation_1hqnuu1">
        <bpmn:targetRef>DataStoreReference_0gccua2</bpmn:targetRef>
      </bpmn:dataOutputAssociation>
    </bpmn:userTask>
    <bpmn:endEvent id="Event_0ps9rih">
      <bpmn:incoming>Flow_0blo8ha</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_0blo8ha" sourceRef="Activity_1kueh7l" targetRef="Event_0ps9rih" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="helloWorld">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="152" y="82" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="158" y="52" width="24" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="DataStoreReference_0gccua2_di" bpmnElement="DataStoreReference_0gccua2">
        <dc:Bounds x="145" y="143" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="159" y="200" width="22" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1bkawer_di" bpmnElement="Activity_1kueh7l">
        <dc:Bounds x="240" y="60" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0ps9rih_di" bpmnElement="Event_0ps9rih">
        <dc:Bounds x="392" y="82" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="DataOutputAssociation_1vlaqwe_di" bpmnElement="DataOutputAssociation_1vlaqwe">
        <di:waypoint x="170" y="118" />
        <di:waypoint x="170" y="143" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_039ivcy_di" bpmnElement="Flow_039ivcy">
        <di:waypoint x="188" y="100" />
        <di:waypoint x="240" y="100" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="DataInputAssociation_18ys0mj_di" bpmnElement="DataInputAssociation_18ys0mj">
        <di:waypoint x="195" y="154" />
        <di:waypoint x="240" y="128" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="DataOutputAssociation_1hqnuu1_di" bpmnElement="DataOutputAssociation_1hqnuu1">
        <di:waypoint x="240" y="128" />
        <di:waypoint x="195" y="154" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0blo8ha_di" bpmnElement="Flow_0blo8ha">
        <di:waypoint x="340" y="100" />
        <di:waypoint x="392" y="100" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
proth1 commented 11 months ago

If you move the execution listener from the Start Event to the Process you also have the same issue.

mike-vasylchenko commented 10 months ago

created PR with additional test that checks generating variables on start and end events https://github.com/softcannery/camunda-formio-accelerator/pull/75