Get list of comments for a process instance

Hello,

How can I get the list of comments (in ascending order) for a process instance?

Thanks.

Hi @yuvrajkeenoo,

You can get a list of Process Instance Comments by using the TaskService#getProcessInstanceComments(ProcessInstanceId) method. However, the comments are sorted in a descending order by the time they were created, and this isn’t modifiable.

Cheers,
Nikola

Hi @nikola.koevski , is there perhaps a REST equivalent to this?

Hi @Prav,

No, currently this is not available through the Rest API. However, it would be an easy-pick to implement it. Would you like to give it a try?

Best,
Nikola

we implemented a custom rest api for this

I used this API but it returns empty list. But the comments are there through the GET task/<task_id>/comment API.

Hi @nikola.koevski

Do you have an example code in using the TaskService.getProcessInstanceComments(ProcessInstanceID) method?

I’m also trying to get the comments made by users on a particular task, place it in a variable and pass it onto another task.

Thank you!

Hi @edcapulong,

Here’s an example on how the Java API can be used:

    TaskService taskService = processEngineConfiguration.getTaskService();
    taskService.getProcessInstanceComments("PROCESS_INSTANCE_ID");
    taskService.getTaskComments("TASK_ID");
    taskService.getTaskComment("TASK_ID", "COMMENT_ID");

Hope it helps!

Best,
Nikola

1 Like

Hi,

I opened a small PR (feat(engine-rest): Add process instance comments rest api by d-michail · Pull Request #1834 · camunda/camunda-bpm-platform · GitHub) which implements this.

Best,
Dimitrios

1 Like