flowable-engine icon indicating copy to clipboard operation
flowable-engine copied to clipboard

setting assignee on DelegateTask in TaskListener does not update history

Open flaviodonze opened this issue 2 years ago • 1 comments

In a org.flowable.engine.delegate.TaskListener setting the assignee (delegateTask.setAssignee()) does store the assignee in [ACT_RU_TASK] but not in [ACT_HI_TASKINST].

public class TestListener implements TaskListener {
	@Override
	public void notify(DelegateTask delegateTask) {
		delegateTask.setAssignee("Person_system");
	}
}
<process id="RequestFeedback" name="RequestFeedback" isExecutable="true">
	<startEvent id="start" flowable:initiator="initiator"/>
	<sequenceFlow id="startToGiveFeedback" sourceRef="start" targetRef="giveFeedback"/>

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

grafik

Using flowable-engine 6.7.2, in activiti V5 setting the assignee also updated the history.

The following workaround forces the engine to update the history:

runtimeService.addEventListener(new FlowableEventListener() {
	@Override
	public void onEvent(FlowableEvent event) {
		FlowableEntityEvent entityEvent = (FlowableEntityEvent) event;
		TaskEntity task = (TaskEntity) entityEvent.getEntity();
		processEngine.getManagementService().executeCommand(new SaveTaskCmd(task));
	}

	@Override
	public boolean isFailOnException() {
		return false;
	}

	@Override
	public String getOnTransaction() {
		return null;
	}

	@Override
	public boolean isFireOnTransactionLifecycleEvent() {
		return false;
	}
}, FlowableEngineEventType.TASK_CREATED);

grafik

flaviodonze avatar Jul 28 '22 08:07 flaviodonze

yes, i have the same problem!

alpeace avatar Sep 02 '22 01:09 alpeace

yes, i have the same problem!

qingquaner avatar Nov 25 '22 16:11 qingquaner

try taskService.setAssignee(delegate.getId(),"chj");

qingquaner avatar Nov 25 '22 16:11 qingquaner

Yes same problem

Yojay97 avatar Apr 20 '23 03:04 Yojay97

Do you set assignee in createListener?

cnless avatar Aug 07 '23 09:08 cnless

Changing the assignee should be done using the TaskService#setAssignee like mentioned by @qingquaner in https://github.com/flowable/flowable-engine/issues/3409#issuecomment-1327699414

filiphr avatar Aug 07 '23 12:08 filiphr