For Each Loop in the Flowchart

Hello everyone,

I think an activity that works as a for each but is used in the flowcharts just would be useful for displaying purposes.

I know that you can use a decision and you can loop through with a counter, but something that would look better and make no use of a counter would be good.

Thanks

We can use for each loop by including a sequence in the flowchart which eliminates the use of a counter variable

Hello,

I think you have to use counter if you want to iterate without using for loop, You can use some smart loop like Do…While in which you just see to set boolean value to come out of loop.

There’s no need of a counter in for-each. In while yes.

Oh, I think I did not make myself right understood.

So, it was looking something like this in my head. When you drag one of these for each loops designed for the flowchart, you would be given two separate activities, one beginning and one end. Whatever is between those two will be the loop. Basically the body of the for each will be a flowchart instead of a sequence.

Just go to Library -> Add Folder and point to a persistent location. Paste your previous .xaml in there and it will be available for drag and drop.

Library-Add%20Folder

Any update on this idea? It is quite useful for presenting the workflow to business.

You can try using state machine. It will be efficient and best for presentation as well. But still you need to use counter.

image

When I was first learning, I would try to loop through items using Decisions and a counter. The logic needed for this was basically consistent but very cluttered, and also can cause some issues where you might not be processing the correct item due to the use of a counter.

While a For each activity for use in a Flowchart could be interesting and something I also pushed for a while ago, it really isn’t needed to be honest, because For each steps are a section of a process; something that should be organized separate from the other portions of the Flowchart.

What I mean by that is, you can place a For each box in your Flow Chart, then delete the Body box in the For each and replace with a Flow chart box, then maximize the Flow Chart in the For each. Now, you have a Flow Chart that is performed in a For each step; now, you can process all your items in a more organized method.

Here is a snippet example of what I mean:

So maybe that can provide some additional ideas of For each use in a Flowchart.

Regards.

5 Likes

Thanks Clayton as always. Really helpful!

I was thinking the same thing as you mentioned. Use counters and loop the flow. Count the total of row first, and start the loop from bottom of the data table.
After finished 1 loop, minus counter by 1. And once counter equals to 0, close the loop.

That would loop your items in reverse which works if that’s what you want, but you can also do the same thing starting with counter = 0 or -1. Then, do counter+1 and have a Decision that checks if the index is > the rows or items count to exit loop.

Although, I switched to using For eaches like I presented above (and to organize the process better), because I got exhausted with all the clutter of performing a simple loop, and would need to help explain it to my colleagues whenever they need to understand it or develop their own loop. :stuck_out_tongue:

2 Likes

I am curious @ClaytonM liske this example , if we use a flowchart in for each loop, the bot performs an activity if true and if false i want the bot to go to the next entry in for each loop, so in that case I dont define anything in false and it would automaticaly perform for the nextone ?

Yep, if I understand you correctly. Essentially, the For Each is going to iterate each item, so if your Flowchart (inside the For Each), ends… as in gets to the last activity where no arrow is directed at another activity… then it goes to next iteration.

2 Likes

Perfect , thanks , this really is a better way to present and declutter the for loops.