Second loop cumul answer on Set. Need reset?

Hello community !

my mind is still weird, I just need a little inspiration from good mind like yours :joy:

Describe the issue/error/question

Function3 take all from Set. But I want only what in the loop.
So 3 times, 3 items.
Function 3 give me; 3 items, 6 items and 9 items (cumulative answers)

I expect this :
Answer n° 1
11, 12, 13
Answer n° 2
21, 22, 23
Answer n° 3
31, 32, 33

What is the error message (if any)?

No error, just a construction workflow

Please share the workflow

Share the output returned by the last node

[
  {
    "data": [
      {
        "itemC": 11
      },
      {
        "itemC": 12
      },
      {
        "itemC": 13
      },
      {
        "itemC": 21
      },
      {
        "itemC": 22
      },
      {
        "itemC": 23
      },
      {
        "itemC": 31
      },
      {
        "itemC": 32
      },
      {
        "itemC": 33
      }
    ]
  }
]

Thanks for your time :innocent:

Hi @Dtneo, from looking through this it’s not clear to me what the loops are achieving here. But on a general level my first suggestion would be to move the inner loop into its own sub-workflow. So something like this for the parent:

And a child workflow like so:

This way you wouldn’t have to wrap your head around building nested loops and resetting them correctly.

Sorry but it doesn’t work :stuck_out_tongue:

Only 1 item
image

That’s because I am not 100% sure what’s expected here. Which data do you want to process in the child workflow (or the sub-loop if you will) and which format exactly do you want the sub-workflow to return for each batch coming from the parent?

You should be able to make adjust the examples accordingly. You can also consider temporarily adding some mock data to the child workflow using the Function node (or Code node if using the latest version of n8n), this should make it much easier to build out the required logic.

1 Like

Thank you for your time. I will work on all of that

With pictures, what I expect will be more clear I hope :slight_smile:



Tbh I think I am a bit lost here. Perhaps we can take this step by step.

For the first iteration of the outer loop, which data exactly do you need to send over to the child workflow (or sub-loop)? And how would the data for second iteration look like?

My current example sends these items over for the first iteration to the child workflow:

This on the second iteration:

And this on the third iteration:

Is this all the data required by the sub-workflow? Or do all items in each iteration need the full D data, e.g. something like this?

1 Like

You solved it (you give me the idea for solved it !!! thank you so much)
the merge had to be on subworkflow.



item3solved

1 Like

Amazing, thanks so much for confirming!

1 Like