I have been trying to display all the comments from a process using the table widget and a groovy script, but always i get an error. I would like to have two columns in the table, one for the “user” who posted the comment and another one for the “comment”
Is there a way to do that?
Hello,
you can retrieve comments by using searchComments method and display them using a table widget, yes. I do not have any code snippet to quickly share, but if you can share your code with us, we might be able to detect together why do you always get an error.
Hope this helps,
Haris
Hi Haris, thanks for your answer.
My code is this:
import java.util.List; import org.bonitasoft.engine.search.SearchResult; import org.bonitasoft.engine.bpm.comment.Comment;SearchResult c = apiAccessor .getProcessAPI().searchComments(null);
List lstComments =c.getResult();
return lstComments;
In the “return type” of the groovy expression I put “java.util.List” and in the table config I create two columns for the headers and a new row for the table variables, in my case " the user" and “the comment”.
Thanks for help.
You cannot pass null in line 5, you have to provide SearchOptions.
You will have to add something like following before your line 5:
SearchOptionsBuilder sob = new SearchOptionsBuilder(0, 100);
SearchOptions so = sob.done();
SearchResult c = apiAccessor .getProcessAPI().searchComments(so);
Note that this will get you first 100 comments from the system. If you want to search more precisely, you can use filters. For example, to get comments from the ongoing process instance, something like:
SearchOptionsBuilder sob = new SearchOptionsBuilder(0, 100);
SearchOptions so = sob.filter(ProcessInstanceSearchDescriptor.ID,processInstanceId).done();
SearchResult c = apiAccessor .getProcessAPI().searchComments(so);
Thanks… u saved my life.