Remove the datarow

Hi Team,

How to delete the data row inside the for each row?
so I need to perform the activities inside the same for each. While removing it is throwing an error.

Thanks
Girish

Hi @Girish,

Once you have done your process with the datarow you can delete it using myTable.Rows.Remove(dr)

@Girish,

Can you tell me the situation to delete the row inside the for each row.

Regards
Balamurugan

Hi @balupad14,

Actually situation is I am looping for each to do some operation, inside for each if item is faulty or error I need to delete it from data table, so updated table after the deletion I will use it for further operation.

Thanks
Girish

Hi @Girish,

Actually, you can’t delete row with “Delete row” activity while you are inside of a loop. I don’t know the main reason to this happen, but may could be that UiPath loses the reference of the rows, because if you try to delete just 1 row inside the loop, it works, but when you try to delete more than 1 row, it fails, so I guess that uipath loses the reference of the rows.

You have to detect which rows you want to delete and then remove them outside the loop (if you are using that activity). Maybe there is any way to delete rows inside a loop but I don’t know how, and it should be done without this activity…

Regards :mage:
Pablo

Look this screenshot, try to do your work like:

imagen

Before, I said you can’t do it inside a loop. Sorry for my mistake, I mean you can’t do it inside “for each row”, but you can make a loop with a while and make a count to go through the DT.

Regards

1 Like

Thank you for you time Pablo. I got the solution for it like skipping the rows after the completion of processing.

Regards
Girish

1 Like

@Girish Nice!! I’m glad to hear that

Bests, :slight_smile:

1 Like