AnsweredAssumed Answered

TaskListener cannot delete potential owners specified in XML

Question asked by processengine on Aug 24, 2012
Latest reply on Jul 12, 2013 by jbarrez
Version: Activiti 5.10 (with setup like in demo via ant demo.start)

In the XML I've defined a user task with a task listener on create event like this:
<userTask id="dynamicAssignmentTask" name="Dynamic Assignment Task" >
        <documentation>Some documentation here</documentation>
        <extensionElements>
          <activiti:taskListener event="create" class="org.activiti.tasklistener.DynamicAssignmentHandler" />
        </extensionElements>
        <potentialOwner>
          <resourceAssignmentExpression>
            <formalExpression>user(kermit), group(DynamicAssignmentGroup)</formalExpression>
          </resourceAssignmentExpression>
        </potentialOwner>
    </userTask>
I would like to reassign the task candidates within the task listener. For example:
@Override
   public void notify(DelegateTask delegateTask) {
      // This doesn't delete the candidate group specified in the XML.
      delegateTask.deleteCandidateGroup("DynamicAssignmentGroup");
      
      // This doesn't delete the user specified in the XML.
      delegateTask.deleteCandidateUser("kermit");

      
      // This is not specified in the XML and works perfectly.
      delegateTask.addCandidateUser("gonzo");
      delegateTask.deleteCandidateUser("gonzo");

   }
The problem is that the candidates which are specified within the XML cannot be deleted (removed from the candidate list) by using the API within a TaskListener. Adding/deleting candidates which aren't specified within the XML works perfectly.
Any ideas why this won't work? (Is it a bug?)

Thanks in advance

Outcomes