• JulesAus
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hello All,

I have a trigger that is a bulk update. Sometimes the same object will make it into my update list more than once, which causes the error

 

UpdateParticipationTrigger: execution of AfterInsert caused by: System.ListException: Duplicate id in list: SomeSalesforceIDHere

 

 My list is built using

 

 

Set<Id> ConIds = new Set<Id> {}; for (Payments__c p : payments) { ConIds.add( p.Contact__c ); }

 

 How can I prevent duplicates from making it into that list, and hence causing errors? I am sure it is very simple to do (basically look in the list to see if the ID we are about to add is already in there, if so, don't add it). Let me know. Thanks!