Set value for variable in groovy in bonita 6.2

Hi
I want to set value for variable in groovy script connector(6.2.6) but no data save on variable.
for example i use these command in groovy script connector(x, y is global variable):

x=10;
y=100;

in the next form x , y is null(in bonita 5.10 it works correctly).
how can i set value for variable that i can use them in another form?

Hello,

in order to set process instances variables you can use Operations (tab “Operations” when you select an activiy in the Studio). If you want to use Grovy Scripty connector you need to use the engine API: Ex:

apiAccessor.getProcessAPI().updateProcessDataInstance(“x”, processInstanceId, 100)

Hello together,

i have a short question about this issue.

We have installed Bonita 6.3.6 (Community Edition) and like to update a process variable out of a groovy script,
we use the following method, but the variables not updated.

apiAccessor.getProcessAPI().updateProcessDataInstance(“var1”, processInstanceId, “key1”)

any ideas?

kind regards

Hi elias.ricken
thanks very much.
that work!

Forgive me but BPM Groovy programming is supposed to be easy,

why do we need to do this to set a variable:

apiAccessor.getProcessAPI().updateProcessDataInstance("x", processInstanceId, 100)

when all we want to do is:

x=100;

Join the Campaign for making BPM programming easier

It does work with simple variables, if not working are you sure “var1” is defined as a string and not an integer?

Lists etc. are a bit different and I must admit to not getting them to work in this manner as yet and use the results script to do it right.

regards
Seán

Hey Sean,

yes i’m sure, var1 and key both are defined as a string, but no variable updates possible.

please could you post a sample groovyscript and your environment specs.

many thx

Ronny

Question, where are you trying to do this?

If it is in the POOL for the instantiation form then this will not work as I’ve found from personal experience, the problem being is that POOL variables are only created after the POOL form is displayed…

see here…

here…

here…

For that matter, my string that have worked are as follows in groovy…

apiAccessor.getProcessAPI().updateProcessDataInstance( "configParmDBHost", processInstanceId, "localhost");

regards