Bug in GetTaskFormModelCmd class in flowable 6.8.0?

Hello,

I have a process like this:

image

The first task has a form with an input field called myVar. The user sets myVar to “yes” and finishes the task.

We are working with historics so if i query the ACT_HI_VARINST table I can see following records:

image

The second task has a similar form with the same input field. Now, the user sets myVar to “no” and finishes the task. The content of the ACT_HI_VARINST table is:

image

The third task has a form that shows myVar value. The user see myVar = “no” and completes the task without passing any value for myVar variable. The ACT_HI_VARINST table doesn’t change.

The problem comes when we get the task form model using taskService.getTaskFormModel method. We expect to see myVar=“no” but it’s value is “yes”.

Debugging the code, I see that when flowable is trying to load the variables’s HashMap in GetTaskFormModelCmd (from historic), first it is loading the task variables in map (no variables added because that form only had an expression field), and then it is loading the process variables.

The problem is that GetTaskFormModelCmd class execute this code (we are using flowable 6.8.0):

                processEngineConfiguration.getHistoryService()
                        .createHistoricVariableInstanceQuery().taskId(taskId).list()
                        .stream()
                        .forEach(variableInstance -> variables.putIfAbsent(variableInstance.getVariableName(), variableInstance.getValue()));

                processEngineConfiguration.getHistoryService()
                        .createHistoricVariableInstanceQuery().processInstanceId(task.getProcessInstanceId()).list()
                        .stream()
                        .forEach(variableInstance -> variables.putIfAbsent(variableInstance.getVariableName(), variableInstance.getValue()));

We see that the process variables are getting by HistoricVariableInstanceQuery, setting processInstanceId predicate. This query returns the 3 records sorted as i showed in the table avobe and the value that is added in HashMap is “yes” because of it is using putIfAbsent method (only first record is added).

Are we doing something wrong or is it a flowable bug?

We can solve the problem passing myVar = no, in that way the command would get myVar value form task variables (only one record) but we would like to know if we have to do that as general rule.

Thanks a lot.

Hello,

We have solved this problem implementing our custom GetTaskFormModelCmd. Its a copy of the GetTaskFormModelCmd implementation included in flowable but we have modified the history variable instance query adding .excludeTaskVariables() predicate:

processEngineConfiguration.getHistoryService()
          .createHistoricVariableInstanceQuery()
              .processInstanceId(task.getProcessInstanceId())
              .excludeTaskVariables()
              .list()
              .stream()
              .forEach(variableInstance -> variables.putIfAbsent(variableInstance.getVariableName(), variableInstance.getValue()));

We don’t understand why other people haven’t got the same problem because we think that it is very usual in, for example, a tipically revision scenary (first revisor user accepts grantting a credit, second revisor user rejects granted credit, and the final user views the final decision, closes the credit request because of he cannot object anything, and subsequently reviews the task in its history).

Thank you all