Is this loop done correctly?

Hello. Is this scenario properly made? I wanted to supplement my automation with such a loop, but it does not want to work. The reason is that I don’t have how to pass a value to an element that checks if the condition is true. For some reason, automation doesn’t see the variable like in this example.

Hey Max,
I am not sure I understand your problem. I’ve run your workflow and it seems to work as intended, meaning looping 10 times. Can you elaborate what is not working for you?

My problem is that the scenario where I used this loop does not see the variable created in the Function item module. The loop is practically the same, only with more elements.

I wonder what could be the reason for this? I don’t see why the loop works once and doesn’t work once.

But the example workflow loop you posted above is working for you as expected?

Yes. I put that loop into another scenario and it stopped working.

This is what my extended loop looks like. The condition module does not see the variable I created in module function items.

To be sure, I put the loops back to their simple former state and it works again. Why then that doesn’t work?

Hey Max,
for this simple kind of looping strategy you might be able to use $runIndex inside your if condition. It will increment once each time the loop runs.

Is this some kind of database? What could be the reason that this solution is not working?

Hey @Max_T,

Can you share the workflow that isn’t working?

When it is failing what is happening? That looks like as long as the If node has a true output it will loop. It could be that it isn’t looping because the output is false or one of the other nodes isn’t outputting anything.

According to these settings, the loop should end after the first execution. The loop does not end, however, and continues

Does the If node return false or true? Unless it returns false it will keep running.

Unfortunately, it’s always True. Until the latter condition is triggered, it is always True.

I would say it is working as expected then, If you are never doing something in that loop to set it to false then it will just loop forever.

Are you talking about the loop with the counter working? In the sense that when the counter has reached a certain value, the loop is over. That would be great, but the question is why it does not work for me. Have you changed anything?

Hey @Max_T,

At the end of your loop you have an If node, If that node is not going to false it will keep looping so you would need to check that has more is showing as false and the other value is less than 0.

I can’t see anything in this thread that would possibly change based on me changing anything though unless I have missed something.