MERGE node downstream of an IF node - Need Help

I can’t figure out how to properly Execute a MERGE node if I only have data on one of the inputs. Here’s the scenario I’m trying to build.

I’m building a workflow to add a student to a class. If the student is not already in our online classroom system I first create the student, then I enroll the Student. To do this all I use an http request node to check if they’re in the system, then an IF node - TRUE if they already exist, FALSE if they aren’t in our system. On the TRUE path I’m using a SET node to assign their student ID to a field, on the FALSE path I’m using an HTTP Request node to Create the student in our system and then SET node to assign the new student ID to a field. Then I want to use a merge field. The problem is only one path will fire after the IF statement, and it looks like my MERGE is waiting for data from the second path. Any idea on what the right approach would be? I tried setting the MERGE node to “Always Output Data” but I’m still not seeing any output when I execute the node.

Hey @Renegade hope all is good.

Why are you using combine mode? Was append not working for you for some reason, I believe the last time we had a conversation the merge node was in append mode which would work for this setup.

Hi Jabbson! Append wasn’t working either. I’ve actually tried all different combinations of the MERGE node and still no output.

I think it was working yesterday, wasn’t it?

No, I had to go back an change the pinned data to trigger this path, then I was able to get the IF statement to work. I’m now working downstream of that IF statement.

I’m trying to execute it right now, but it doesn’t proceed. Any idea what I should change?

Change back to append, try to execute and show a screenshot of that

I can try to take a look, but I will need you to pin the data and share the workflow again.

From what we had yesterday, my execution looks like this:

As you can see I also have the node in append mode and it goes through to the merge node without any issues.

Yeah you’re doing what I want to do! Okay, is there a way for me to post my code without all my API calls?

Yeah, it goes past the Merge node for me:

I’m still stuck with a mystery, how do I get it to work for me? I’m struggling with n8n so much lol.

I just wouldn’t use the merge node to begin with here, there is nothing to merge here. Remove the Merge node and try.

Thanks Jabbson, I’ll give that a try, makes sense.

1 Like

Let me know how it goes

I still need to have some type of if statement to get the student ID. I need that field to enroll the student, and I have to get the value either from the Create Student http request or from the Check if user exists mode. That’s why I was trying to use the merge node. Is there a way to use the Variable “student_id” that I created in the SET nodes without referring to the node?

Isn’t it the user_id that you set in the Set nodes?

Yes, is there a way to reference this variable without calling it from the node it was set in? Do I use an expression?

Yes, in the HTTP Request node you can use

{{ $json.user_id }}

to reference the value from previous node.

1 Like