I expect the workflow to return a JSON object containing updates that need to be made to a Google contact. Once I have all the objects, I will send them to Google in an API call.
I just discovered that if I embed the workflow call in another loop, the loop does execute. It’s not running any of the nodes that don’t get run with the closed loop above, but all the data is being processed…
Here’s what I mean. In workflow #1, I have an “Execute a workflow” node:
I format the data before calling workflow #2.
When I configure a loop in workflow #1, or workflow #2, The workflow will stop at the larger merge node in workflow #2.
If I configure a loop in both workflow #2 and #2, then the second loop will loop the workflow.
I’m not sure if this gives any insight into why the workflow stops, but it’s another data point.
For the loop to work it needs to loop back to the start but every node needs to output data otherwise the loop will stop so I suspect in this case one of the nodes is not returning the data needed and that is causing it to stop.
You can work around this by setting the node to always output data under the settings but this does also mean you can get empty data so you will need to make sure you use if nodes to make sure you have data to process.
A merge node typically needs all of the inputs to have data before it will output, Looking at your earlier screenshot you can see where some of the set nodes don’t have data so the big merge only half runs which means the next merge doesn’t get the input it needs to continue.
I have been using merge nodes in this way in several workflows. In this flow specifically, I have to compare the contact card fields in Google Contacts with our master records in HaloPSA.
To do so, I break down the fields so I have the same list from each platform. (Client, ClientID, Firstname, Lastname, EmailAddress, WorkPhone, WorkCell, HomeCell)
Field comparison in the switch node
If the fields matche, nothing further is done with that field.
If HaloFirstname != GoogleFirstname, go down this path.
Set the update variable
Merge the data that comes out.
Make the updated JSON to send to Google.
Send it.
Loop to the next record.
Now you are telling me this shouldn’t work. So my question is, how should I have built this?
I think the switch node is right, but I’m going to get all permutations of fields to update. How should I be building the JSON to send to Google?
It depends on the the option being used in the merge node but looking at your workflow we can see it is stopping because there is no input it looks like the switch is using always output data so it is unusual that it has not outputted any data which would have worked around the problem as all of your outputs should have something so there could be an issue there.
Can you share some example input data that I can use for testing?
The fact remains that I have a loop that will complete a single run if the end node is not connected to the start node of the loop. If I connect the end node to the start of the loop, the loop terminates in the middle.
This is inconsistent behavior. The data being processed is the same.
It was inferred that I’m doing this wrong. I’m told that merge nodes need every input to pass data before they trigger. I am curious, because I’ve been using the fact that they don’t all need to have data, particularly with data that may or may not have every field that other records have. For example, we have contact records that may have a telephone number in any combination of three fields, or none. I have the merge node accepting input from the three chains that process each phone number. When they finish, the merge node appends one after the other, if more than one exists. I then wrap the resulting JSON in the object they need to get processed by the receiving server. This is how I’m building the JSON body for the web call.
If I’m doing this wrong, I need to know where to get information on how to do it right.
If what I have written above is a valid n8n construct, I’d like to know that as well.
On several workflows, when I build a flow with data to loop through, if I close the loop, the flow stops in the middle of the flow. However, if I don’t close the loop, the flow runs to the end of the first contact without issue.
I need to know if I’m I doing this wrong, and if so, how should I be doing this.
I’m left hanging here in the lurch at this time.
I’m having trouble with looping and/or merging in the referenced thread. I kinda feel like I’m being hung out to dry now, as the last reply from anyone was 9 days ago. I need some closure on this.
No error message. The flow just terminates as described in the referenced thread.
I did share my workflow, on that thread.
There is no output, as the flow ends.
Information on your n8n setup
n8n version: 1.60.1
Database (default: SQLite): PostgresQL 15
n8n EXECUTIONS_PROCESS setting (default: own, main): main
Running n8n via (Docker, npm, n8n cloud, desktop app): Docker on Digital Ocean
However, I felt I was being ignored after 9 days with zero replies from anyone but me.
Don’t get me wrong. I’ve been doing technical support and IT for over 30 years, starting with anti-virus software on the telephone because we did not yet have the internet. Almost all of it online in some form. Compuserve and AOL before the 'net came along.
In this case, you can see I replied to this thread twice in that 9 days, and not a single reply acknoledging my comment, that someone was looking into it, or anything. I felt I could have bumped it up in perpetuity and not gotten a reply. I felt I needed to do something to get someone elses attention, especially after two message stating “I still have this issue.” How should a person escalate such a situation? I know if I let an issue languish for 9 days with the user blowing in the wind, my boss would (in the vernacular of the 80s and 90s) ream me a new one.
I suspect it’s a bug, but some sort of reply would have been appropriate. I hope you understand the frustration from this side of the keyboard. I will post another reply with the technical stuff.
I included 5 records. When you execute that node, it runs all the way to the end without issue. This means the contact being processed is ready to be added to Google.
Now, to see it stop in the middle with the same data, connect a return path from the NOOP node at the end of the flow to the input for the “Create Contact Loop” node. Run the workflow with this one change, and it stops at the HaloPSA Merge Numbers node.
That happens because the Merge node does not receive data for all inputs.
I see two options how to mitigate this:
Instead of the Switch node with all edits nodes, use one Edit fields node and set the values for fields if they are present, or set some empty values, if absent
Use code node to manually build the JSON as it’s quite easier to do it there (I can help with that a little bit later)