Iterate datatable rows and skip row if condition is met


i have data-table stores data from from Excel file, using the “Get Row Item” activity i am typing the value into an application using “Type Into” Activity with expression - //row.itemArray(0).ToString//. i have condition if the value of the row does not appear while searching on the application i wanted it to skip to the next row and loop each row until it find the search result in the application.

i tried few thing and it did not work and i am just a beginner to programming and condition

i am using If statement below “Element Exist” Activity and it works, but i dont know how to increment to the next row.

please guide me.


You can use For each row activity to loop all the rows and you can use the Get Row Item activity inside the for each.

1 Like

As @sarathi125 has said, use a for each and the row index can be placed into a variable:

1 Like

Searching through the Accounts.xaml (44.9 KB)

Dears,i have uploaded my Xaml file, i am using the For each row activity. still i could not understand.
picture contains were i stuck. picture is part of the xaml file.

You are using for each activity not for each row activity. Use for each row activity, you will get the properties.

1 Like

you can use ForEach as well, as long as the datatype is set to System.Data.Datarow and your object is an array of data rows (datatable.rows)

@ Madhavi, hi i am using the “for each row” the looping working fine and incremental is working fine,but what i wanted to achieve is how to increment if an if condition fails within the current For Each row loop.

You could use a Continue Activity.


That would be quite a standard thing. If a condition is met, then continue to the next for each iteration, else, carry out some task.

1 Like

Even though if there is a condition failing, if you haven’t specified a break activity within for each row, automatically the control will increment the element.
But if you are speaking about an unexpected exception inside the loop, then enclose the section inside the for each row (body sequence) in try catch block and when an exception occurs, the control then goes to the next element.

Can you please explain the flow where you are facing a break now. and if you can send the workflow, we can review and update it

1 Like

Thank you once again,

i have only one for each row loop starts for a each number in a datatable, for loop starts with the 1st mobile number and searches the service provider website to download the bill, during this it goes through series of condition in that one if condition is when it tries to search a for mobile number and service provider website does not return a result, at this stage i want to increment to next number, if the number is found it will navigate to next page and download the bill.

Also i will try your suggestion of enclosing this condition at the body sequence and let you know,
i have attached the workflow for you review

Searching through the Accounts.xaml (44.9 KB)

@Madhavi Thank you so much, it worked after moving the condition into the body of the for each row loop.

1 Like

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