AnsweredAssumed Answered

Associate a Comment with a UserTask at creation time?

Question asked by mindcrime on Apr 15, 2013
Latest reply on Apr 22, 2013 by mindcrime
Hi all, quick question… my client has a requirement regarding tracking history which seems to map well to the Comments
facility.  As such, I'm trying to associate a comment with a UserTask from within a TaskListener which is bound to the "create" event.  My code looks like this:

public class AddInitialCommentListener implements TaskListener
{

   @Override
   public void notify( DelegateTask task )
   {
      System.out.println( "UpdateInitialCommentListener fired!");
      
      ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
      TaskService taskService = engine.getTaskService();
      System.out.println( "taskId is: " + task.getId());
      taskService.addComment(task.getId(), null, "UserTask CREATED" );
   
      System.out.println( "added comment for task: " + task.getId());
   }
}

But, while this finds the correct taskId and throws no errors, the comment never appears in the database.  It seems to fail silently for some reason.

Should this work? If not, is there some other way to achieve the same effect?   This is Activiti 5.10, FWIW.

Outcomes