Merge Variables Node - Only first input updates during a loop

We are trying to build a component within a recursive loop which takes widget inputs, and passes the new variables back to the start of the loop. This is run on Server (but the question is independent of Server):

2 issues came up:

  1. Recursive loop end does not pass back variables to the start of the loop (even if the variables are in the data stream). The solution to this seems to be to convert the variables to another table and use 2-port Loop Start and End.
  2. The second issue is the Merge Variables node within the component. Only the FIRST variable (when converted to data) seems to come back when the loop is run. When the first input is swapped with something else, only that returns in the loop, but none of the others update.

Sample attached.

  1. ModelNo is the first into the Merge variable so it updates when the loop is run, while neither Customer nor Door Definition update:

  2. Now, Model number is placed as the second input into the Merge Variables node and Customer is placed first, Customer updates in the loop but Model number does not.

It looks like whatever is first in the Merge Variables will update when the recursive runs, anything which is not first will not be updated. Any thoughts?

Merge_Var_Error.knwf (28.8 KB)

I don’t have server so I haven’t really been able to work through your workflow with the interactive widgets (or I just don’t know how to use them), but if I add a Table Creator node in at the end, to pass the following data to the second port of the Recursive End Loop


Then on the second and subsequent iterations, these values are coming through as the collected data


So that would suggest to me that the recursive loop does pass all the data items on the second port back to the loop start.

And just as I was collecting screen shots, I think it’s led me to your problem:
This is the output of your Column Rename:

And this is the input of my test table (based on your original data table)

The column name is possibly the problem, or maybe “a” problem! You’ve named it “Values” instead of “Value”. What happens when you correct that?

Hope that helps! :slight_smile:

Actually, whilst what I found above may have been an issue, it isn’t the cause of your problem.

I’ve just been playing and made it into a workflow I can test by replacing the widgets into Java Edit Variable. With each of those Java nodes modifying one variable.

What is happening (I think) is that all of the flow variables flow via all of your widgets. So the first widget is supplying ALL flow variables. Then the second widget does the same, as does the third. So at the point the flows meet in Merge Variables you have three almost identical sets of flow variables from three sources, each of which modifies just one flow value.

I am guessing then that the presence of a flow variable of a given name on the FIRST widget, trumps any other flow variables of that same name arriving via widgets two and three. Hence you will find that whichever widget is first, will be used to supply ALL the flow variables. That is why only the first widget has it’s changed value going around the loop. I don’t know this for sure, but it would be my guess at what is happening.


I think I now know what the answer to your problem is. Your three widgets need to return a variable that is NOT in the dataflow that has been supplied to them, so instead of them returning the variables
ModelNo, Customer and DoorDefinitionArch

change them so that they return the variables:
ModelNoMod, CustomerMod and DoorDefinitionArchMod

This ensures that those are unique names within the flow that is supplied to Merge Variables. Then on the other side of Merge variables, add a node into the flow to put those “Mod” versions of the variables back into their required variable names in the flow.


This is your demo but with the widget nodes as Java Edit variables just for demo purposes. On each iteration, a letter “x”,“y” or “z” is appended to the end of Customer, DoorDefinitionArch and ModelNo so you can see that each iteration carries through all changes from the previous iteration.

Merge_Var_Error_demo_with_java_edit_variables.knwf (40.4 KB)

(sorry about this being a series of replies rather than one single reply, but that’s just the way I was thinking this through and it wouldn’t have made sense to try to combine these responses as I was in each case thinking about it from a new angle, or trying to work out how I could test a theory in my environment !)

1 Like

Thanks @takbb for your investigation!
I came across the Values/Value issue and it likely had a part to play. However, the major issue was with the Merge Variables node. I made the variables go sequentially from one widget to the next and eliminated the Merge Variables node, now it works perfectly. So it looks like a Merge Variable node bug at not capturing variables properly.

I don’t think it’s a bug as such in Merge Node, but the problem is that each flow to each widget carries all the flow variables with it. Unfortunately you can’t “filter out” the other flow variables that you are wanting handled by the other widgets. As a result each widget supplies its copy of all the flow variables, and in the Merge Variables node (now that I’ve read it’s documentation, lol), it says

Note, if there are the same variables defined in different inputs, the standard conflict handling is applied: Top most inputs take priority and define the value of a variable.

So we both live and learn! :slight_smile: Anyway glad you fixed your problem

1 Like

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