For Each Row in Data Table: Collection was modified; enumeration operation might not execute

Hello Experts!
While executing my code this showing an error.

Please refer to attached workflow
Uipath.zip (63.7 KB)

Hello,

This happens when you try to add a row to the same datatable which we are looping through. The solution is to copy the datatable to a new one and add datarows to the newly created one. You can do it like this:
DTNew= DTOld.Copy()

Thanks!
Athira

Thanks mam, i getting it.

But will your please elaborate the process in more easily manner where and what i have to place.
I am freshly new to UIpath.

Hi @Prabin_Chand,

You can try with the following additions.

image
image

Regards,
MY

1 Like

hello sir,
its throwing an error.


Try like this!

if (row(0).tostring.equals(item(1).Tostring))

if you wants to remove the duplicates from the data table try like this

dt.Defaultview.ToTable(True)

Regards,

1 Like

are you trying to remove row from

dtReportIDOT

or

dtSalesDoc
?? @Prabin_Chand

dtReportIDO

try this @Prabin_Chand
Main.xaml (25.6 KB)

LOL. That’s not the output i want…
This is hillarious

this
Main.xaml (24.0 KB)

1 Like

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