How can we add a process comment with APIs ?

1
+1
-1

Hi !

I'm trying to add a comment to the process programmaticaly.
I have tried to add a connectorOUT, which takes my comment value from the form contract, and then call this code :

apiAccessor.processAPI.addProcessComment(processInstanceId, myCommentContract)

The problem is that the comment is added by the System User, and thus is not visible on the Comments Page.

Is there a way to add a comment to the Comments Page ?

Things I could try :

  • In a connector OUT : get the taskPerformerID, connect him, and execute "addProcessComment"

OR

  • In the form : call the REST API (POST /bonita/API/bpm/comment ) on the submit button OnClick (is it possible ?)

Thanks :)

Comments

Submitted by yajita.y on Wed, 03/08/2017 - 14:19

debes agregar el comentario en las acciones de una tarea humana, ahí te salen registradas con el usuario logeado

You must add the comment in the actions of a human task, there they are registered with the loggeduser

Submitted by p.clainchard on Thu, 03/09/2017 - 10:24

I understand that, but how can it be done ?
If I do it in a script from the designer, the loggedUser is "System".

I managed to add a comment from a form page, using a button that calls the REST API api/bpm/comment, but that implies my user to click on one button to submit the comment, and then on an other to submit the form.

One solution could be to create a new custom button that calls the API, and then calls the submit form action ? Not sure if we can do it ?

Submitted by yajita.y on Thu, 03/09/2017 - 14:34

I use this within a human task action, and it is saved when the form is submitted. By rest api there is no way.

try{
apiAccessor.getProcessAPI().addProcessComment(rootProcessInstanceId, field_comentario1);
}catch(Exception e){}
"";
https://yajitam.wordpress.com/2017/03/09/bonita-anadir-comentario-con-no...

Submitted by p.clainchard on Mon, 04/24/2017 - 10:08

That does not work anymore in Bonita 7.

All the scripts are executed by the system user

3 answers

1
0
-1

Hi
This is Totally Possible. I had a similar Situation a while ago.
But I created a Custom Button Widget to solve my Problem.

You need to pass a Payload along with the POST event of the Button click.

The Payload should Contain the Process Instance Id and Comment value.
I modified the Regular Button to add two new Sections.
1) Comment Url - ../API/bpm/comment
2) Comment Payload - use a JavaScript expression to return a value like below.

return{
"processInstanceId" : $data.task.caseId,
"content" : "XYZ Team - " +$data.formInput.comments
};
You can also try by using a POST event . The URl to call should be ../API/bpm/comment
and Data sent on click should be Payload variable.
This helped me to add Case comments with Correct username instead of Default System username.

One major drawback of this is when user tried to submit a Form, and there is some input missing.
the form would keep throwing error but comments would get logged with each button clicks.Hence Duplicate comments appears.

Hope this Helps.

1
0
-1

Rest API comments is not avalaible in version 7.1.5
This is a alternative
https://yajitam.wordpress.com/2017/03/09/bonita-anadir-comentario-con-no...

1
-1
-1

Answer deleted -- sorry: it didn’t answer your question.
(I should read more carefully before I post :) )

Notifications