AnsweredAssumed Answered

Job in ACT_RU_JOB not being removed.

Question asked by richard1 on Mar 31, 2011
Latest reply on Apr 4, 2011 by frederikheremans1
Hello all,
   I have an interesting problem with a TaskListener that I added to a UserTask for a CREATE event. I would like for it to check for a variable and if set to true set the DelegateTask to complete. I believe the correct way to do this would be to have an ExclusiveGateway before it and have that determine if the UserTask should be skipped or not. I chose to do it the wrong way since this skipping mechanism is only used by developers as we are testing and playing around and does not need to be visible to business analysts. I was able to do what I wanted to do by casting the DelegateTask passed to the notify method to a TaskEntity. From the TaskEntity I call complete(). This does what I want but I have run into another problem, which I believe was due to me breaking the rules. If I add a BoundaryEvent Timer to that UserTask, bad things happen. The tasks completes as we want but the Job in the ACT_RU_JOB table remains and then tries to fire at the desired time. This fails since the task it was attached to already completed and remains in the ACT_RU_JOB table until I manually remove it. Is this due to me breaking the rules or is it a bug? Is there a better way to do this within the TaskListener?

Thank You

Code Snippet:

  void notify(DelegateTask task) {
    //Casting to TaskEntity which is overkill since I am using Groovy, but there for dramatic effect
    TaskEntity entity = task;

    String mySkip = skip?.getValue(task)?.toString();

    if (mySkip && mySkip.equalsIgnoreCase('true')) {
      //Only update if we are in a CREATE listener
      if (entity.getEventName()?.equals(EVENTNAME_CREATE)) {
        //Bad things happen If there is a timer attached to the task