4 Replies Latest reply on Apr 13, 2010 3:04 AM by hongvo

    Adding comments to an execution?

    hongvo

      Hi all,

       

      I'm a newbie to jBPM, hope someone can help me here

       

      I'm currently using jBPM 4.3. I'm trying to add comments to a process instance/execution, but I just can't make it work.

       

      The API description for HistoryComment states the following:

       

      "a free text comment that can be made to an Execution or a task".

       

      I'm only able to find method for adding comments to a task through the taskService.addTaskComment(java.lang.String taskId,                java.lang.String message), but found none for relating comments to an execution/process instance itself.

       

      Does anyone know how I can make this work? I see that the database table JBPM4_HIST_DETAIL contains references to process instance id, but I don't know how to set this.

       

      Also, the user id is always null for all the comments. I noticed there are some jiras trying to fix this. Anyone who knows if there has been any progress with this issue?

       

      Thanks in advance for all the help

       

      Best regards,

       

      Hong Vo

        • 1. Re: Adding comments to an execution?
          I'm facing the exact same problem, would love an answer
          • 2. Re: Adding comments to an execution?
            rmoskal

            I've been creating a task for holding process comments/discussions. I store a reference to it on a process variable.Kludgy, but it works.

             

            The user id is picked up from the jbpm context when there is some authenticated user.  I'm not sure exactly where it is picked up and it would be nice to be able to set it manually.

             

            regards,

             

             

            Robert Moskal
            Brooklyn, USA

            • 3. Re: Adding comments to an execution?

              I took a dirtier approach,something like:

               

              List<HistoryTask> executionTasks = pe.getHistoryService().createHistoryTaskQuery().executionId(task.getExecutionId()).orderAsc(TaskQuery.PROPERTY_CREATEDATE).list();

               

                      for (HistoryTask executionTask : executionTasks){

                          List<HistoryComment> comments = taskService.getTaskComments(executionTask.getId());

                          //... merge all comments in one big list

              }

               

              ie listing all comments of all the tasks in the execution ID, I hope it doesn't hit my systems performance too hard

              • 4. Re: Adding comments to an execution?
                hongvo

                Thanks for all the replies!

                 

                We ended up using our own custom object Comment with all the fields we needed (because we also had to keep track of who added the comment). Then we stored the whole object in a list of comments as a variable. It worked well for us