Java Snippet return multiple variable

Good morning,

I am trying to update a couple of variables via the Java snippet (Java Edit Variable) node

My question is on multiple output to variable. I have the basic structure.

testOne = “false”;
testTwo = 'false";

if (condition1 == true){
testOne = “true”;
else if (condition2 == true){
testTwo = 'true";

However I’m using the Java Edit Variable node and it only seems to be able to edit one variable.

As in this scenario both conditions should evaluate to true. but it is only marking the first variable as true and doesn’t seem to evaluate the “if-else” if the first condition is true. Is is possible to update multiple variables using this node as outputs?

Thanks in advance.

Yes, it’s possible two create/overwrite multiple flow variables with the Java Edit Variable Node. However, they way your wrote that snippet, testTwo will only be set to “true” when condition1 is false and condition2 is true. The “else if”-condition will only be checked if the “if”-condition was false. If you want to test the conditions independently (i.e. check condition2 regardless of the value of condition1) you need to write:

if (condition1 == true) {
testOne = “false”;
if (condition2 == true) {
testTwo = “false”;


Thanks @Thyme it has been a minute since I’ve coded. Appreciate the help.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.