Script task javascript

how do I get the value of two variables that were filled in a form so I can do a calculation with them in a script task. EX: in the form was filled in the variable x and y in the next task of the stream which is a script task would like to subtract x from y (x-y) and put the result into a new variable.

When the form is submitted, the data is saved as process variables.

in your script you use something like

var var1 = execution.getVariable("myvar1");
var var2 = execution.getVariable("myvar2");
var var3 = var1 - var2;
execution.setVariable("subtractionResult", var3);

See the docs for the “execution” variable, and using “DelegateExecution”: https://docs.camunda.org/javadoc/camunda-bpm-platform/7.7/org/camunda/bpm/engine/delegate/DelegateExecution.html

1 Like

tanks StephenOTT. It worked