# How to change assignee field for HistoricActivityInstance

**URL:** <https://forum.flowable.org/t/how-to-change-assignee-field-for-historicactivityinstance/7585>\
**Category:** Flowable Engine\
**Created:** [March 9, 2021, 3:27pm UTC](https://forum.flowable.org/t/how-to-change-assignee-field-for-historicactivityinstance/7585 "2021-03-09T15:27:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akki](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@akki](https://forum.flowable.org/u/akki)\
**Post date:** [March 9, 2021, 3:27pm UTC](https://forum.flowable.org/t/how-to-change-assignee-field-for-historicactivityinstance/7585/1 "2021-03-09T15:27:09Z")

</div>

Hi, I have a listener listening to `FlowableEngineEventType.TASK_ASSIGNED` event.  
Below is a **rough** example of the custom listener:

**TestListener.java**

```
 public class TestListener implements FlowableEventListener
 {
     @Override
     public void onEvent( FlowableEvent event )
     {
         FlowableEngineEventType lEventType = (FlowableEngineEventType) event.getType();
 
         switch( lEventType )
         {
             case TASK_ASSIGNED:
                 if( event instanceof FlowableEntityEventImpl
                     && ( (FlowableEntityEventImpl) event ).getEntity() instanceof TaskEntityImpl )
                 {
                     TaskEntityImpl lTaskImpl = (TaskEntityImpl) ( (FlowableEntityEventImpl) event ).getEntity();
                     if( lTaskImpl.getAssignee() != null && lTaskImpl.getAssignee().equalsIgnoreCase( "TEST" ) )
                         lTaskImpl.setAssignee( "ADMIN" );
                     }
                     
                 }
                 break;
             default:
                 break;
         }
 
     }
     //other inherited method implementations
 }

```

With this `lTaskImpl.setAssignee( "ADMIN" );` I’m able to change the assignee for the given `user task` from “TEST” user to “ADMIN”. But I get the old Assignee value i.e. “TEST” for the custom history APIs, which try to retrieve data from table `act_hi_actinst`

```
List<HistoricActivityInstance> historyList = mHistoryService.createHistoricActivityInstanceQuery()
                                                                    .processInstanceId( processInstanceId )
                                                                    .orderByHistoricActivityInstanceEndTime()
                                                                    .desc()
                                                                    .list()

```

**Is there a way I can change the data of the history table as well while changing the assignee in TASK\_ASSIGNED event?**.

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [March 9, 2021, 3:37pm UTC](https://forum.flowable.org/t/how-to-change-assignee-field-for-historicactivityinstance/7585/2 "2021-03-09T15:37:53Z")

</div>

Hi akki,

have a look on `TaskServiceImpl`

```auto
    @Override
    public void setAssignee(String taskId, String userId) {
        commandExecutor.execute(new AddIdentityLinkCmd(taskId, userId, AddIdentityLinkCmd.IDENTITY_USER, IdentityLinkType.ASSIGNEE));
    }

```

`org.flowable.engine.impl.cmd.AddIdentityLinkCmd#execute` uses `TaskHelper.changeTaskAssignee(task, identityId);` dig little bit deeper into the source code and do exactly the same as `TaskServiceImp` is doing.  
The problem could be that assignee is overridden after your update, but I would not expect it if you listener partially works.

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![akki](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@akki](https://forum.flowable.org/u/akki)\
**Post date:** [March 9, 2021, 3:43pm UTC](https://forum.flowable.org/t/how-to-change-assignee-field-for-historicactivityinstance/7585/3 "2021-03-09T15:43:02Z")

</div>

Thanks for the reply. I’ll look into this.
