Row Index in for each row in data table

Hello guys i have used a for each row data table and created a variable to get the rowindex.

The condition in if activity satisfy it will in add 1 to rowindex and break the for each and should move to the next row.

problem:-

it is taking the next row data after break activity but the row index is not adding it is still 0 for the next row data also.

so is there any solution for this.

1 Like

@Gokul_Murali
For the activity ‘For Each Row’, when you set the variable for Index, it’ll automatically increase by 1 after finishing one iteration.
Just remove the assign to check the message box.

1 Like

i removed the assign activity still index is zero but it is moving to the next row.

I have used a break activity in if condition under for each is it because of that.

1 Like

@Gokul_Murali ,

Index starts from 0

Change your condition to RowIndex = 0

Thanks,
Ashok :slight_smile:

1 Like

@Gokul_Murali

1 Like

But i created a variable Rowindex in foreach activity it is already coming as “0”

1 Like

RowIndex will increase only after completing that Body sequence. As you are breaking it in middle, it’s not getting increase.

1 Like

I’m not sure what you are trying to achieve but if you want to process first row of the datable, you can use dt.Rows(0)

1 Like

Have you tested with Continue instead of Break? Break will exit the For loop. If you need to continue the next row, you should use Contiune.

1 Like

See i have an excel

image

if the remarks contain “Document attached successfully in dms” , it should go to the next row and and the index should be “1”

1 Like
  1. Index is zero base.
  2. Like ptrobot said, you should use Continue instead of Break.
1 Like

i have also used the same code but the row index is not increasing after break activity.

1 Like

Use Continue then try debug the process. You’ll see what the robot is doing.

1 Like

@healsko_ho

I changed the break with continue the problem is that row index is increasing but the row data is not looping it is showing only first data

1 Like

The updated data is in your row variable. E.g. your If condition should be:

row("Remarks").ToString.Contains("Document Attached Successfully in DMS")

1 Like

@ptrobot

Yeah i made changes like that even after the row index is not increasing but is moving to the next row data

1 Like

Would you provide the screenshot of your updated workflow?

@healsko_ho

@Gokul_Murali ,

Use this workflow. You don’t need to increase the RowIndex manually.

DataTableIteration.xaml (9.9 KB)

Code:

Output:

Thanks,
Ashok

@ashokkarale

Thank you somuch bro

1 Like