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

Duplicate in list. Any suggestions?
Hi All,
i am geting this error when i attch an image to master object (in file and attchments) and the detail object have records.i am also updating master object when a new detail record is added and approved.
it seems that adding an image trigers the loop.
Error: Apex trigger trgOrphanImage caused an unexpected exception, contact your administrator: trgOrphanImage: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id a0H2000000A5UtqEAF; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, trgAnnualProgressReportIns: execution of AfterUpdate caused by: System.ListException: Duplicate id in list: a0A2000000KkOr2EAF Class.AnnualReportUpdBiodata.updBiodata: line 96, column 1 Trigger.trgAnnualProgressReportIns: line 49, column 1: []: Trigger.trgOrphanImage: line 59, column 1
i am geting this error when i attch an image to master object (in file and attchments) and the detail object have records.i am also updating master object when a new detail record is added and approved.
it seems that adding an image trigers the loop.
Error: Apex trigger trgOrphanImage caused an unexpected exception, contact your administrator: trgOrphanImage: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id a0H2000000A5UtqEAF; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, trgAnnualProgressReportIns: execution of AfterUpdate caused by: System.ListException: Duplicate id in list: a0A2000000KkOr2EAF Class.AnnualReportUpdBiodata.updBiodata: line 96, column 1 Trigger.trgAnnualProgressReportIns: line 49, column 1: []: Trigger.trgOrphanImage: line 59, column 1
If list have a duplicate element then you can use set instead of list set works just like list but it have a diffrence that it doesn't store duplicate value.
for example you can use if statement to do this,
if(!myupdatelist.conatins(rec.id))
myupdatelist.add(rec);
thanks,
For apex basics you can visit this: http://www.cloudforce4u.com/2014/07/salesforce-apex-for-beginners.html