You need to sign in to do that
Don't have an account?

Cannot modify a collection while it is being iterated + apex error
Hello Peers,
can someone help me to resolve this issue.I am not able to understand how to fix it.
Thanks In Advance
can someone help me to resolve this issue.I am not able to understand how to fix it.
Thanks In Advance
I have faced the same issue. below is dummy example for good understanding. Solution : => if you stuck in this problam then you can store list in separate variable called x and for loop use separate variable called Y and simply modify the x list.
your problam will be resolved.
don't forget to mark it as best answer.
Thank you
All Answers
The problem is that you are modifying a list of records that you are iterating over. Lets take the following snippet from your code as an example
WRONG
Above code should be like this :-
CORRECT
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
I have faced the same issue. below is dummy example for good understanding. Solution : => if you stuck in this problam then you can store list in separate variable called x and for loop use separate variable called Y and simply modify the x list.
your problam will be resolved.
don't forget to mark it as best answer.
Thank you