How to Add Action on button

i create on form and on text field ‘cmnt’

I want to add a comment with a data from a form field ‘cmnt’ , I can add an action to the form and write the next groovy code:

apiAccessor.getProcessAPI().addComment(rootProcessInstanceId, field_TextField1);

for that i done following .
now in submit’s button’s > general tab > action >
add action
now there is two field

---- takes value of -----
now exactly where i have to write code ?

i tried by
---- takes value of -Code = give error
Variable – takes value of – Code = give error

what mistake i m doing

Thanks in advance

create a boolean variable, and return true or false, something like that.

did you try to clic on the small pen icon on the right of the field ? it opens a window, and you can choose different of value (constant, script, …)

Ya i know where to write script
But
There are two field in button > action

  1. Field not allow to write script it just allow variable

(Takes value of )

  1. Field where i wrote actully script

But it can’t run without 1st field fill
So i create one var and put into first field
Then try to run process
After click on submit
It prompt “error while submit form”

what does your scprit return ? the aim of the action is to return something in the variable you set in the first field…

Yup that is
My script is not return anything
It will just add comment of forms field into dashbord’s commnet
So how can i achive that

1 how can i add action without return anything
As per above script
Or
I have to return anythin dummy and save to variable?

Thank You so so so much , It works perfectly fine
Thanks again