Reference id is erased for historical plan item instance


I’ve designed a CMMN case that contains a ProcessTask referencing a BPMN workflow:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="" xmlns:xsi="" xmlns:flowable="" xmlns:cmmndi="" xmlns:dc="" xmlns:di="" targetNamespace="">
  <case id="my-case" name="my-case" flowable:initiatorVariableName="initiator">
    <casePlanModel id="casePlanModel" name="My Case" flowable:formFieldValidation="true">
      <planItem id="planItem1" name="preparation" definitionRef="sid-F67AD90C-5EDB-4746-A078-AA1E82339169" />
      <processTask id="sid-F67AD90C-5EDB-4746-A078-AA1E82339169" name="preparation" flowable:fallbackToDefaultTenant="false">

The referenced BPMN workflow contains some UserTask.

When I launch an instance of the case, I manage to access the tasks created by the BPMN via the reference id of the PlanItemInstance as it is equals to the BPMN process id :

CaseInstance → PlanItemInstance – (reference id) -> ProcessInstance → Task

But when it comes to historical objects, the link between HistoricalPlanItemInstance and HistoricalProcessInstance is broken (reference id is null) so I can’t access the historical tasks created by the process instance.

Any idea how to workaround this issue ?

Thank you

That’s indeed a bug and has been discovered and fixed on master: flowable-engine/ at master · flowable/flowable-engine · GitHub

The only way to fix it, would be to change the HistoryManager with a custom implementation that executes the logic that is done here: Fix referenceId and referenceType not set on the HistoricPlanItemInst… · flowable/flowable-engine@a4302d8 · GitHub

Thank you for your reply.

Finally, I had to implement a workaround by keeping the reference in a local variable on completion:

taskService.setVariableLocal(task.getId(), "planItemInstanceId", planItemInstance.getId());