For Each Row in data table is going to start of loop again


#1

Hi,
I have read the data from Xls and put that into Data table . Now I have used for each row in data table function to enter data from data table in to the application. It is entering data but after data from all rows are entered Loop does not exit but it tries to enter data of first row again into the application.
I have cross checked the data in Data table by displaying it in a message box and it is showing same number of rows as there in Xls.
Can someone help on this.


#2

Hi,
Could you please upload workflow .


#3

Please see- https://www.screencast.com/t/IlgQOnBIxi


#4

:neutral_face: blocked by company network.


#5

2017-09-05_1606


#6

Sorry pal.Can’t say much looking into screen shot.Anyway you could do below steps to stop the looping.

  • Check number of row by “datatable.Rows.Count.ToString.”
  • then create a counter variable cnt and increase the count in every iteration (cnt=cnt+1)
  • use if condition to check whether cnt =no.rows of datatable if true then use "Break" Activity to come out of For loop.

#7

OK Thanks , I’ll try this


#8

I have tried this, and it works. But what if I want to re-enter the loop on the next row?
If I break my loop will not continue to increment.

I am looping until I get a condition = true. If it happens I will break, write in Excel, and start from the beginning.

If false, it will continue to do some other code. It is too much code for me to put in “else”. And it is occuring several places in the code. So I need an easy way of skipping a line in Excel/row


#9

instead of using Break, what else can I use to continue to next sequence when IF Condition satisfied?