Identify end of for each row


Is it possible if we use for each row and identify end of row lines,
if it end of row, then we add new data row in the datatable.
Is there any way to done it?


1 Like

@mashy2 Yes you can use Datatable.Rows.count which gives number of rows in a datatable

we wont be able to add a row inside a for each row loop while the datatable is in iteration
–so what we can do use better use FOR EACH loop instead of FOR EACH ROW LOOP
–where the input should be like this
Datatablename.Rows and the type argument should be like System.Data.Datarow
–then inside the loop if we want to refer the row we can mention like this
item(“yourcolumnname”) which will give the value of the current row with the mentioned columnname
–so inside the loop it is same as for each row loop but we need small changes in the methods we use and i hope that would be fine
–now use a assign activity as a first activity inside the for each loop
counter = counter + 1
where counter is a int32 variable with default value as 0
–then use a if condition atlast of the loop like this
counter > datatablename.Rows.Count
if that is true it will go to THEN part where we can use a add datarow activity to add a datarow at last where mention the datatable name as input in datatable property and in datarow property mention as datatablename.NewRow

–next to this inside the THEN part use a break activity

hope this would help you
Cheers @mashy2

1 Like

To find the last row index of datable → DataTable.Rows.Count

To add a new row, use Add Data Row activity.

Input for Add data Row activity:

  1. DataTable name
    2)Array or dataRow

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