How does one implement the 'Comment' feature via Activiti Designer?

cancel
Showing results for 
Search instead for 
Did you mean: 
Member II

How does one implement the 'Comment' feature via Activiti Designer?

Meaning, I currently use Activiti Designer to build user task forms.  If I want to add a field for comments, what is the best way to make use of the existing act_hi_comment db table to store the comment?  I tried adding a field of type comment but nothing appears on the form.  I also did not get any errors recorded when I executed the task, which I would have expected if it was an invalid formtype.  Any suggestions?

3 Replies
Established Member II

Re: How does one implement the 'Comment' feature via Activiti Designer?

This thread here from 2013 sheds a little bit of light on the ACT_HI_COMMENT table, how to access it, and what exactly is stored there. It appears that in 2013, this was not fully implemented and the only way to add a comment to a task was through the Java API. However, now it seems that a REST endpoint has been added, as explained here.

I'm not entirely sure what you're referring to with the 'field of type comment' - so you might be onto something there? Maybe give a little bit more detail on that?


It seems like, from the implementation details that the comment field isn't really intended to be used as an active user integration within a form, but I suppose its possible to use it in this manner. While the first method that comes to mind would be a little bit long, here it is:

  1. Create a new form stencil that includes a 'Comment' field that would show up in the Form Editor toolbar on the left.
  2. Create the additional Java code necessary to handle the additional form field type, that would include posting to the REST API for the given process instance.

I'm very accustomed to adding unusual customizations to the app, so that's where my bias for creating my own field comes from  Let's dig a little bit deeper and see what options are available.

-JEarles

Member II

Re: How does one implement the 'Comment' feature via Activiti Designer?

Thank you for taking the time to respond to my question.

While the ' ACT_HI_COMMENT ' table will accept input via use of Java APIs, I was hoping I could leverage from it when creating user forms/tasks with Activiti Designer.  I realize one can create custom types to introduce new field types , but if I'm not mistaken, these are subsequently recorded to the ACT_RU_VARIABLE and ACT_HI_VARINST table.  Unfortunately, the constraint of varchar2(2000) does not bode well when 'collecting' use input across a number of tasks for a given workflow.  In the workflow, we have a number of review steps, where one will provide a disposition and comments.  The desire is to provide visibility to all of these comments at any subsequent task in the flow.  I currently have a working solution whereby the user can click on a button on the form, which will launch a pop up window that displays a concatenation of all the comments.  When I recently noticed the existence of the ACT_HI_COMMENTS table, I thought there might be an opportunity to perform this processing in a more effective and efficient manner. 

I've attached an example image of my attempt to use 'comment'  in Activiti Designer when building the form.  I understand why it doesn't work as is, I was just trying to figure out how I could provide a user input field mapped to this comments table. All our workflows are generated via the Activiti Designer.

Established Member II

Re: How does one implement the 'Comment' feature via Activiti Designer?

I wasn't aware of this, but I just found a previous question that highlights how to save a comment to a live ProcessInstance. Here is the rest of the API documentation referring to the Comment interface. So you could have the user enter a comment that stored in a local variable, then you save the comment using:

TaskService.addComment(String taskId, String processInstanceId, String type, String message)

then get them back with the taskService:

TaskService.getTaskComments(String taskId)

TaskService.getProcessInstanceComments(String processInstanceId)

Is that more of what you're looking for? It looks like those comments get saved in the ACT_HI_COMMENT table, also.

If you wanted a more custom solution:

Another (more free form) way to do what you're proposing would be to create your own new DB table, where you can use any length of VARCHAR necessary, that would store an association of comments and a TASK_ID_. Then access it similar to my previous suggestion by creating the additional REST layer in Java that would return the comment list. Although, since you already have a working solution, developing all of the additional code base might not be worth it.