Check next row of datatable and act if it contains certain string

Hey guys, i’ve seen similar questions here before but can’t really translate the answers into what i need so i’ll see if someone knows how to solve this.

I need to be able to while in an for each row activity, check the next(upcoming)row for a certain value using “.contains” and if there is a match, perform an action. I know i need to use something like “rowindex+1” in an IF activity. But cant get it to work. Right now im at something like this:

But row(currentindex+1).tostring.Contains (“PATEAM”) give me an error saying that column 1 cant be found. So it’s not looking at the next row but the next column.
What would the correct statement be for it to check the next row, not the next column?

@thomasb82

Check below for your reference
RPA DataTable: Get Previous Row Column Value, Set to Current Row Column Value

Hope this helps you

Follow Link

Thanks

@thomasb82
find some starter help here:
ForEach_AlsoNextRowIndex.xaml (8.3 KB)

Alternate 2:
ForEach_ProcessRow_N+1AndAlsoN.xaml (8.3 KB)

They thomasb82

You can just use DT_filteredData1.rows(currentindex+1).item(0).ToString.contains(“PATEAM”)

where 0 is the index of your column (in this case the first).

Kind regards, Anders

Thanks guys, used anders solution and it worked great!

1 Like

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