Java Snippet Set Flow Variable by Name

How do I set a Flow Variable within a Java Snippet by its name?

I'm looking for the Java Snippet equivalent of:

pushFlowVariableDouble(nameOfFlowVariable, 99.99);

When I need to change the values in a Column by its name in a Java Snippet I follow these steps:

1. Use the Java Snippet to create a new column

2. Use the same Java Snippet to create a nameOfColumn Flow Variable

3. Use a Column Filter to remove the old column

4. Use a Column Rename (RegEx) to rename the new column, sticking the nameOfColumn in the replaceString in the Flow Variable tab

In principle I should be able to follow the same steps to set a Flow Variable by Name. Unfortunately there is no "Column Rename" equivalent for Flow Variables (there is no "Flow Variable Rename").

I'm trying to tune a model by iteratively changing a set of input Flow Variables. For example, at the end of the first loop I determine that I should try modifying Flow Variable #3. Then at the end of the second loop I determine that I should try modifying Flow Variable #7. And so on.

 

I'm not sure what you're trying to do is the best way. You could, for example, use a table of parameters in a (recursive) loop. Or maybe the Parameter Optimization Loop is already sufficient?

If you still want to do it your way: You can access Flow Variables by name, but only in the Java Edit Variable Node, as far as i've gathered. See its description for details. Why the methods are not available anywhere else, I have no idea.