Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-9249

Under circumstances history for Variables is on process start not created

XMLWordPrintable

      Given:

      • Process with an non-interrupting conditional EventSubProcess

      When:

      • Process instance is created with variables which triggers this event process

      Then:

      • History for all given variables are not written.

      Observation:

      It seems that the Listener which writes the history for the variable events is not called.
      This is because ExecutionEntity#isAutoFireHistoryEvents returns false in ExecutionEntity#getVariableInstanceLifecycleListeners.

      Please see the attached unit test and process model to reproduce this bug.

      Example:

              RuntimeService runtimeService = processEngineRule.getRuntimeService();
              
              Map<String, Object> variables = new HashMap<>();
              variables.put("startTimer", 1L);
              variables.put("duration", "PT2S");
      
              final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("sample", "0815", variables);
      
              TaskService taskService = processEngineRule.getTaskService();
              Task task = taskService.createTaskQuery().singleResult();
              if (task != null) {
                  assertEquals("init process", task.getName());
                  taskService.complete(task.getId());
              }
      
              assertEquals(processEngineRule
                .getHistoryService()
                .createHistoricVariableInstanceQuery()
                .count(), 2L); // fails
      

      Workaround:

      
              RuntimeService runtimeService = processEngineRule.getRuntimeService();
              
              Map<String, Object> variables = new HashMap<>();
      //        variables.put("startTimer", 1L);
              variables.put("duration", "PT2S");
      
              final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("sample", "0815", variables);
      
              runtimeService.setVariable(processInstance.getProcessInstanceId(), "startTimer", 1L);
      
              TaskService taskService = processEngineRule.getTaskService();
              Task task = taskService.createTaskQuery().singleResult();
              if (task != null) {
                  assertEquals("init process", task.getName());
                  taskService.complete(task.getId());
              }
      
              assertEquals(processEngineRule
                .getHistoryService()
                .createHistoricVariableInstanceQuery()
                .count(), 2L);
      

        This is the controller panel for Smart Panels app

              Unassigned Unassigned
              christopher.zell Christopher Kujawa
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: