Use the Table widget to display comments from the process

1
0
-1

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?

1 answer

1
0
-1
This one is the BEST answer!

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

Comments

Submitted by darkmk40 on Tue, 07/22/2014 - 15:30

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<Comment> c = apiAccessor .getProcessAPI().searchComments(null);
List<Comment> 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.

Submitted by haris.subasic on Tue, 07/22/2014 - 16:17

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<Comment> 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<Comment> c = apiAccessor .getProcessAPI().searchComments(so);
Submitted by darkmk40 on Tue, 07/22/2014 - 16:33

Thanks.... u saved my life.

:)

Notifications