How to increment a loop counter variable across several nodes

I set a counter variable “retryCount” to 0.

Und some conditions I wannt to iterate the loop once again at a maximum of 5 times. So I increment the counter. But on the beginning of the loop, the input variable “retryCount” is still “0” and has no change.
Both of this here doesn’t work:

Thx for your help.

Hey @FN2208 !
I think you can make use of the built‑in runtime variable $runindex.

If you want to check how many times a different node has run, you can also use that node’s run index in a Code node or expression, for example:

{{ $node[“Some Node”].runIndex }}.

In my case i just wanna know when a certain inner Loop has run morre than n times, so i can do something else(i am just restating calling an workflow).

Heres how i use the $runindex :

And here is rhe context :

So when the inner loop has runned more than n times goes to true.

P.S

Mathematical operations as well

{{ $runIndex + 1 }} // add 1

{{ $runIndex * 10 }} // multiply by 10

{{ $runIndex >= 5 ? ‘high’ : ‘low’ }} // combine with a condition

Merry Christmas !
Cheers!

Thank you. I will try it soon.

Merry Christmas!

I have tried it now and it works. Thank you very much! :grinning_face:

1 Like