# Use the Table widget to display comments from the process

**URL:** <https://community.ofelia.com/t/use-the-table-widget-to-display-comments-from-the-process/4895>\
**Category:** Q&A\
**Created:** [21 July 2014 15:21 UTC](https://community.ofelia.com/t/use-the-table-widget-to-display-comments-from-the-process/4895 "2014-07-21T15:21:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![darkmk40](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@darkmk40](https://community.ofelia.com/u/darkmk40)\
**Post date:** [21 July 2014 15:21 UTC](https://community.ofelia.com/t/use-the-table-widget-to-display-comments-from-the-process/4895/1 "2014-07-21T15:21:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![haris.subasic](https://avatars.discourse-cdn.com/v4/letter/h/5daacb/32.png) [@haris.subasic](https://community.ofelia.com/u/haris.subasic)\
**Post date:** [22 July 2014 09:29 UTC](https://community.ofelia.com/t/use-the-table-widget-to-display-comments-from-the-process/4895/2 "2014-07-22T09:29:41Z")

</div>

Hello,  
you can retrieve comments by using [searchComments](http://documentation.bonitasoft.com/javadoc/api/6.3/org/bonitasoft/engine/api/ProcessRuntimeAPI.html#searchComments%28org.bonitasoft.engine.search.SearchOptions%29) 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

---

<div class="post-metadata">

**Author:** ![darkmk40](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@darkmk40](https://community.ofelia.com/u/darkmk40)\
**Post date:** [22 July 2014 13:30 UTC](https://community.ofelia.com/t/use-the-table-widget-to-display-comments-from-the-process/4895/3 "2014-07-22T13:30:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![haris.subasic](https://avatars.discourse-cdn.com/v4/letter/h/5daacb/32.png) [@haris.subasic](https://community.ofelia.com/u/haris.subasic)\
**Post date:** [22 July 2014 14:17 UTC](https://community.ofelia.com/t/use-the-table-widget-to-display-comments-from-the-process/4895/4 "2014-07-22T14:17:09Z")

</div>

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);

---

<div class="post-metadata">

**Author:** ![darkmk40](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@darkmk40](https://community.ofelia.com/u/darkmk40)\
**Post date:** [22 July 2014 14:33 UTC](https://community.ofelia.com/t/use-the-table-widget-to-display-comments-from-the-process/4895/5 "2014-07-22T14:33:02Z")

</div>

Thanks… u saved my life.

🙂
