function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Johny ABU HANAJohny ABU HANA 

Cannot modify a collection while it is being iterated

Hi all
I need some advise on the following error "Cannot modify a collection while it is being iterated" 

what can be the issue.

we have checked if the code does any update on loop however we did not find any 

please advise ASAP

regards
Johny
NagendraNagendra (Salesforce Developers) 
Hi Johny,

Sorry for this issue you are facing.

This exception occurs because you are trying to modify some record while you are iterating the same record.
 
Suggestions: have you add any trigger for this record related object. check for that. Triggers has more potential for this exception

Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
Anant KamatAnant Kamat
Hi Johny,
Can you paste the code which is throwing this error so that it would be easy to identify the issue.