Collection error

Hii,

project.zip (90.8 KB)
Xaml file attached below

Please help me out
Thanks and Regards,
Supriya

Hi @supu123,
You are writing a new line after every iteration of for each loop. The process won’t allow to modify the data table while iterating. You can build a new data table instead of writing in the same sheet. That will resolve your issue :slight_smile:

Credits : from net
You cannot add or remove an item from a collection as you are iterating over it in a foreach . Your options are to make a local copy of the list prior to the loop, loop over the copy, and add or remove from the original. Or you can keep a separate list of items to remove after you finish the original loop. Or you can switch to a for loop and iterate over it backwards, which allows you to remove items from the end as you go.

@supu123
Buddy find the tweaked xaml with this attached folder

project.zip (91.7 KB)

Just made changes in reading the mail xaml with Ticket for each row loop with a for each loop (not for each row loop). The reason is as the for each row iterates through the datatable, you cannot add the datarow to the table , while its getting iterated, its like boarding a fast running train, that wont happen right buddy…thats why. so if we iterate each row one by one with for each loop taking each datarow one by one wont affect buddy…

Hope this would help you

Cheers…!

Hiii @Palaniyappan

Its not working
Again the same error

Please look into it
Project1.zip (92.2 KB)

Thanks and Regards,
Supriya

Hope we found buddy,
@supu123
Place the write range activity like this buddy, at last in reading the mail xaml buddy

the reason is add data row is executing and closing and is getting to next activity write range activity in log message of your image, and its getting closed from there on rather it didnt iterate…so thats why i tried this

Lets try this out buddy

Cheers…!

Hii @Palaniyappan
Its not working
Same error again

Thanks and Regards,
Supriya

Buddy remove all the write range in if and else part also and keep as one write range at last of the sequence buddy

Hi @Palaniyappan
reading the mail.zip (6.4 KB)
Removed from all if conditions only

Thanks and Regards,
Supriya

Buddy it is still inside the for each loop buddy, better keep the write range outside here in flow chart next to for each loop and then followed by output data table

image
Lets try this and sort this out buddy…its easy

Cheers…

Hi @Palaniyappan
if the write range is out of the for loop then


This message box is displayed and even after adding one row in excel then also it is agin showing no rows in ticket file

Thanks and Regards,
Supriya

@supu123
Buddy i think its not because of keeping the write range activity out of for each loop activity, the reason why you got this is because of message box that is something from different process, like this which occurs three steps before write range

Kindly remove this check buddy it will work, lets sort this out

My kind suggetion is to get to know this, kindly add them as write line activity or log message activity so that you can view that later rather interrupting the bot execution buddy.
Hope this would help you
image

Cheers.

@supu123
is this working buddy
let resolve this either if not, but that should work as it looks perfect

Cheers…