How to add data row to a datatable using value from for each row

Hi dev, pls assist, I have a for each row activity inside the for each row, I have added add data row and specified in array row as {row(“amt”).tostring} but I got error – collection-was-modified-enumeration-operation-might-not-execute, please how do I execute?

Hi @RPA-botDev

Have a look on the thread

Regards
Gokul

hey

try with that
image

regards!

Hi @RPA-botDev ,

I suspect that there is a schema mismatch.
Could you maybe tell us a little more by sharing few screenshots or the xaml itself?

Its difficult for us to pinpoint the issue as the information provided is less.

Also, if your DataTable contains more than one Column, then you should pass in all the items in the array, not just the item you want to update.

Kind Regards,
Ashwin A.K

you CANNOT modify a datatable (e.g. add row) while in a foreach loop of the SAME datatable.
so you should do this instead

  1. define new datatable variable e.g. dt2
  2. copy dt1 to dt2 using dt1.Copy
  3. loop over dt2 then in add row, add to dt1, that way it works