cancel
Showing results for 
Search instead for 
Did you mean: 

Event never thrown when task assigned in user code.

rosselet
Champ in-the-making
Champ in-the-making
in TaskEntity.java I see this @ line 547

    // if there is no command context, then it means that the user is calling the
    // setAssignee outside a service method.  E.g. while creating a new task.
    if (commandContext!=null) {
      commandContext
        .getHistoryManager()
        .recordTaskAssigneeChange(id, assignee);
     
      if (assignee != null && processInstanceId != null) {
        getProcessInstance().involveUser(assignee, IdentityLinkType.PARTICIPANT);
      }
    
      if(!StringUtils.equals(initialAssignee, assignee)) {
         fireEvent(TaskListener.EVENTNAME_ASSIGNMENT);
         initialAssignee = assignee;
      }

this means that assignment events never thrown when assignment happens in user code?  Why not - what is the logic behind this?  I would like to have a manager to set the assignee for a task when the task is unassigned, and for an ASSIGNMENT event to be thrown in the same manner as a COMPLETE event is thrown if I call complete on a task from my code.   Is it possible that the involveuser/throw here could/should be moved to outside the commandContext check?  Or is there a way to set the commandContext from our code?
Cheers
Ati
1 REPLY 1

rosselet
Champ in-the-making
Champ in-the-making
Sorry… just found my problem.
if I set it using the task.setAssignee() method and then use the taskService.saveTask, it works fine.   I just had
<code>
activiti:taskListener event="assign" …
</code>
instead of
<code>
activiti:taskListener event="assignment" …
</code>
in my bpmn.20.xml file.   Interesting that it didn't complain on validation though.