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

System.ListException: Duplicate id in list
Hi
I am having the above error and i understand that its beacuse i am updating my object over and over . As the if contion is true i am updating again and again. Can anyone please suggest a work around as how i can have updates even after if conditions.
trigger APFileUpdates on Files__c (after insert) { Thank you. |
Hi Brad,
Your code contains query inside a for loop which would throw exception at time of bulk insertion.
I have optimised the code for you, check if it helps:
All Answers
I took a quick stab not knowing your use case. The Duplicate ID issue was due to the multiple UpdaeAPApp.add(App) for the same APP row.
Hi,
Thank you for your response. Yes its due to multiple updates on the same App obj based on the if condition. Is there a work around to fix this issue. Please provide any sample if you do have that would be greatly helpful .
Thank you,
Try changing your collection from List to Set, since Set maintains unique values.
Hi Brad,
Your code contains query inside a for loop which would throw exception at time of bulk insertion.
I have optimised the code for you, check if it helps:
Um, yea, I rewrote your code in my post and the solution was there. HOWEVER, Rahul also solved the issue you did not inquire about and it should be used as it addresses the bulk data issue which I did not address.
Hi Rahul ,
Thank you so much for your time and response it worked. But the obly change i did was
if(mapApp.contains(file.AP_Application__c)) says incorrect signature of Map<Id,Ap_Application> with contains method.
So when i removed that if condition it worked fine as i already do get the related list.
Thank you once again.
Hi Starzz,
Yes solution did work.
Thank you for your time and effort starzz.