Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting assignee on DelegateTask is not stored in HistoricTaskInstance #3973

Open
flaviodonze opened this issue Jun 21, 2022 · 3 comments
Open

Comments

@flaviodonze
Copy link

flaviodonze commented Jun 21, 2022

After using a org.activiti.engine.delegate.TaskListener to set the assignee of a DelegateTask, the HistoricTaskInstance.assignee is not set.

public class TestListener implements TaskListener {
	@Override
	public void notify(DelegateTask delegateTask) {
		delegateTask.setAssignee("Person_system");
	}
}
<process id="TestFlow" isExecutable="true">
	<startEvent id="start" activiti:initiator="initiator"/>
	<sequenceFlow id="startToForward" sourceRef="start" targetRef="testListener"/>

	<userTask id="testListener" name="testListener">
		<extensionElements>
			<activiti:taskListener event="create" class="TestListener" />
		</extensionElements>
	</userTask>
        .....

Using the taskservice works, taskService.createTaskQuery().list() I get the task with correct assignee set:
grafik

Using the historyservice results in outdated tasks: historyService.createHistoricTaskInstanceQuery().list()
grafik

Results in an empty array: historyService.createHistoricTaskInstanceQuery().taskAssignee("Person_system").list();

Using Activiti Version 7.3.0

UPDATE: Just verified the same issue in Activiti Version 6.0.0

@flaviodonze flaviodonze changed the title changes on DelegateTask not stored in history setting assignee on DelegateTask is not stored in HistoricTaskInstance Jun 28, 2022
@flaviodonze
Copy link
Author

Here a print-screen which shows the error in the database, comparing the two task tables of the running and history:

grafik

@flaviodonze
Copy link
Author

Here is a workaround I came up with, this fixes the issue in the database, ACT_HI_TASKINST contains the assignee.

// TODO: Hack to make sure history-task is updated with active-task (e.g. assignee), required after update V5 > V6
// https://github.com/Activiti/Activiti/issues/3973
runtimeService.addEventListener(new ActivitiEventListener() {
	@Override
	public void onEvent(ActivitiEvent event) {
		ActivitiEntityEvent entityEvent = (ActivitiEntityEvent) event;
		TaskEntity task = (TaskEntity) entityEvent.getEntity();
		processEngine.getManagementService().executeCommand(new SaveTaskCmd(task));
	}

	@Override
	public boolean isFailOnException() {
		return false;
	}
}, ActivitiEventType.TASK_CREATED);

@THLIVSQAZ
Copy link

same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants