Help me improve my workflow

Describe the problem/error/question

can’t use itmes from if noted to insert or mark sync success, i am very new to this

What is the error message (if any)?

NO

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @CfhKyle,

Please can you elaborate more on what you’re actually trying to achieve. What is your use case, the expected outcome and the current outcome?

We’re not sure what you’re trying to build here

  1. I am trying to sync user data from the user table to the user_copy table.
  2. The output of the “have records” node is the data I want to pass to both the “insert user_copy” and “mark sync success” nodes.
  3. I originally thought I couldn’t directly use the output of the “have records” node, so I used a Code node to return its data.
  4. Now I’m not sure whether I’m using the nodes in the correct way, or if there is a better and more idiomatic approach in n8n.

These 2 code node is kind of weird.

return $('set fiellds').all();

return $('have records').all();

If you want to use the data or item from previous node. Just use expression

$('node name').item.json

i get u @darrell_tw ,How to set up this node

You have one of two options:

  1. Auto map the data (which is what you have selected there)
  2. Manually map each field. (The easier option in this case)

For option 1, if you want the sql node to auto insert values, then you need to create a Set node right before this one and map out the data to exactly match the column names of the table you’re trying to insert into. In this case you can use Darylls suggestion to reference previous node by name

So your set fields node will look like this, then you can delete the code node.

To shorted your workflow even more, I would opt for option 2 where you get rid of the leading set node and just reference the data the same way using a manual mapping on the insert sql node