Reference a node output value while looping

Hi there, I am trying to create a workflow where if the condition fails (“if current stage is valid” node), it should re-run the “Verify Stage” node.

On the first run, data from the “*Inject Data” node is getting passed to the “Verify Stage” node and works perfectly fine but on the second run, I am not able to pass data. I want to pass data from the *Inject Data” node with a slight modification to it. How can I do that?

Hey @n8n_vikas!

Welcome to the community! :slightly_smiling_face:

One of the approaches you can take is as follows.
Use a Set node to set a variable. Connect this Set node with the False branch of the IF node. In your *Inject Data node, check if the value you’ve set in the Set node is available (or is not undefined). Based on that you can return the modified output that the Verify Stage can use.

Hope this helps.

You can also access all the data of the “*Inject Data” node in the Function-Node ("???") with $node["*Inject Data"].json, then you can do your transformation and output it again.

Here the documentation:

If you need the data of all the items you can also use $items():

1 Like

Thank you @harshil1712 for your response. I went with @jan 's suggestion as it was easier for me.

This was super easy. Thank you @jan. This is my first workflow btw :sweat_smile:

Great to hear!

Wow then you did dive into something quite deep from the start :wink:

Have fun!