Can you edit Flow Variables within CASE Switch Variable Nodes?

I have been trying to edit flow variables within a case switch variable node.

What I’m noticing is that the variable is being manipulated correctly within the switch start and end points. However, downstream of the “CASE Switch Variable (End)” node any manipulation does not persist, it instead retains the value it had prior to entering the “CASE Switch Variable (Start)” node.

Is this a bug, or are flow variables being treated locally within switch statements intentionally?

Either way I am able to use the java code snippet to get around this issue, but was just curious.

Attached is a workflow that demonstrates the above question.

Flow variable manipulation in switches.knwf (132.7 KB)

I think what you are seeing is what is described in the original Vernalis flow variable port switching nodes:

NOTE - Due to the way in which flow variables are handled within KNIME, no matter which the active branch, the flow variable values for any existing flow variables beyond the corresponding “end” node will be those at the top-most port of the “end” node. New variables created in any active branch will retain their correct values. If you need to change the value of existing variables, please either use a new flow variable, or use a variable to tablerow node before a conventional End IF node.

An alternative workaround without Java Snippet is sugested there too.


1 Like