Issue with a loop in flows

Why doesn’t this work?
It only loops once and then just ends the flow.

Hi @suhi10jr

Welcome to the forums!

The Flows variables X and Y you have will only fire one time on the first iteration. Flows variables don’t currently work in loops, although we are going to be fixing this in the near future.

Based on what I can see from your flow, it looks like you’re trying to loop through Y until you find a value that matches X and then output the index.

Try the below flow changes as it will send all the info on each iteration of the loop so you don’t have the issue with the variables:

a record (JSON) is constructed, the index value is incremented by 1, and then the check is performed. If it’s false, the record is re-sent to the evaluate block, if it’s true, then the record is output and you can select the index.

Let me know if this works for you.

Thank you! Works well, just very slow. Is there any more optimized way to do this?

Hi @suhi10jr

You could use the $filter function to get the matching element (if it exists) but it wouldn’t return the index if you need that.

That could work, but i tried the filter function and just nothing happened. I was probably doing something wrong.

Try this, it will output a list of the value found, if it finds it more than once, it will be a list with duplicate elements:

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