For each row & Add data row : Collection was modified; enumeration operation might not execute


Hi All,

I am facing the error i.e. " Collection was modified; enumeration operation might not execute." while using add data row in for each datatable.

in this add data row I am passing lookup variable here I am write that data on a particular column.

Hi,

We cannot add or remove row which is iterated collection in for each loop.
If you need to just update target column value in existing rows, Can you try as the following?

image

Regards,

I am lookup the dt and write value through add data row

Hi,

If you need to add rows to dt_consolidate, the following RepeatNumberOfTimes activity might help you.

Regards,

I am sharing code with you.
test.xaml (17.2 KB)

Hi,

Can you share what you want to achieve?

Regards,

input.xlsx (12.0 KB)
In this file there is an output sheet in which i have shared output of this process.

Hi,

Probably, you don’t need to use AddDataRow.
In this case, can you try to put Assign just after LookupDataTable as the following?

Regards,

ok I’ll try