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
Ckevin1984Ckevin1984 

Question about test trigger error message

I met a problem when i run the test method on my trigger.Can anyone help me to find out the problem.Thanks for any help

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TimeSheetTrigger: execution of AfterInsert caused by: System.ListException: Duplicate id in list: 701R0000000EUYBIA4 Trigger.TimeSheetTrigger: line 61, column 1: []

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard
Judging by the error message, you have a list of objects that you are trying to update or insert, and the same record appears more than once in the list. You may want to consider putting the records into a map keyed by id, as that will ensure you only have a single record per entry, albeit the last one that you put into the map will be the version that is retained. As the previous poster said, if you can post the trigger, we should be able to give you specific help rather than general suggestions.

All Answers

iBr0theriBr0ther

it would be great if you post your trigger body here.

bob_buzzardbob_buzzard
Judging by the error message, you have a list of objects that you are trying to update or insert, and the same record appears more than once in the list. You may want to consider putting the records into a map keyed by id, as that will ensure you only have a single record per entry, albeit the last one that you put into the map will be the version that is retained. As the previous poster said, if you can post the trigger, we should be able to give you specific help rather than general suggestions.
This was selected as the best answer