How to run a part of a workflow more than once?

I have a workflow where I want to have it run more than one time. How do I do that?

Thx :slight_smile:

Hi @ManyQuestions :wave:

Check out this workflow - Add a check condition for a loop in n8n | n8n workflow template It’ll check how often the loop has ran, which sounds perfect for what you’re looking for here :slight_smile:

2 Likes

Hi @EmeraldHerald this is alomst good. Trouble: I need it to pass along all items.
When i use it inside my workflow, and the workflow has two runs, it only passes along one run:

Could you try a different runIndex and see if that fixes this up? Something like “smaller than” and “5” in your if node? I just want to see if the way that you’ve currently set that up is causing it to not push over all the data :+1:

1 Like

@EmeraldHerald almost working now. How can i reset the looped part of the workflow?

@EmeraldHerald an example:

Hi @ManyQuestions :wave: Hope you had a good weekend!

I’m not too sure what you mean both by your question on the canvas, and also what you mean by “resetting the looped part of the workflow” - can you elaborate a bit and maybe give an example?

For instance, when you say “data from a previous node”, does your previous node always produce exactly one result which you want to reference in every loop?

If you could give an example with the data you’re passing on from that node and what exactly you’d like to see every loop, that’d be really helpful!

2 Likes

Hi @EmeraldHerald , i made a short video: New Recording - 4.7.2023, 10:48:04

Run 1: 8 imtes,
Run 2: 1 item.

But run two should take the complete data from the first part of the workflow and run them again.

SCR-20230704-kgrt

Hi @ManyQuestions :wave: Can you try using {{ $("Data from previous nodes").first(0, 0).json.propertyName }} instead as your expression?

You can see where I grabbed this idea from here: Built in methods and variables reference | n8n Docs

Using your example workflow:

Let me know if that helps!

3 Likes

Looks like it’s working now. Thanks alot for the help and the advice with the variables.

2 Likes

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