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
plapla 

System.FinalException: Cannot modify a collection while it is being iterated.

Hello,

 

All of a sudden one of my test class failed and displayed the following error message. It was working fine before. It does not show what lines in the class caused the error. Any ideas? . Please advice. Thanks

 

System.FinalException: Cannot modify a collection while it is being iterated.

 

Paul

 

 

Chamil MadusankaChamil Madusanka

This exception is occurred because you are trying to modify some record while you are iterating same record.

 

Suggestions : have you add any trigger for this record related object. check for that. Triggers has more potential for this exception

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit

plapla

Thanks for you reply. It's fixed now.

 

Paul