Using UiPath after a hot minute, and I’ve noticed that the For Each activity has changed from the standard ‘For each i in ___’ to this new one where it asks for a list of items and has this ‘Item’ argument (see attached).
I am not familiar with this version of the activity - I need to loop through a range from 1 to about 50 to repeat a certain click on a website. How can I achieve this on the new for loop? Thanks for any help in advance.
How about using the Repeat Number of Times activity instead?
If you storing the numbers in an Array, In assign activity take an variable lets say “ArrayNumbers”. Variable type will be Array(Int32) and use the below syntax.
If you storing the numbers in an List, In assign activity take an variable lets say “ListNumbers”. Variable type will be List(Int32)(i.e “System.Collections.Generic.List(Int32)”) and use the below syntax.
You can use that either of one in For Each Loop or you can give “Enumerable.Range(1,50)” directly in for Each Loop. It will work.
Hope it helps!!
Hi all, thanks for your replies. I actually forgot to mention that I need the loop number (the incremented i) for the automation to work. How can I get this number to use as a variable?
In the “For Each” Activity Properties Panel There is an Option to create “Index” .There you can create a variable .Lets Say Count.
The Initial Value of the Varibale Count will be 0.Then it will be auto incremented as your loop executes.
So you can use that Variable Count according to your requirement.
The “currentItem” variable in the Repeat Number of Times activity gives you the index of the iteration. There’s no need to use an Enumerable.Range nor a separate Index variable to get the current iteration as you would in a For Each activity.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.