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
Michelle GrantMichelle Grant 

System.listexception: row with duplicate name

We have a test class that is now failing with this error:

System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AssetTrigger: execution of AfterInsert
caused by: System.DmlException: Update failed. First exception on row 0 with id 0016C000007X172QAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AccountTrigger: execution of BeforeUpdate
caused by: System.ListException: Row with duplicate Name at index: 2
Trigger.AccountTrigger: line 48, column 1: []
Class.dlrs.RollupService.Updater.updateRecords: line 1248, column 1 Class.dlrs.RollupService.UpdateWithoutSharing.updateRecords: line 1291, column 1 Class.dlrs.RollupService.updateRecords: line 1219, column 1 Class.dlrs.RollupService.handleRollups: line 855, column 1 Class.dlrs.RollupService.rollup: line 205, column 1 Trigger.AssetTrigger: line 40, column 1: []


I assume the main issue is the duplicate row name so I searched arounf for that. I saw this thread https://developer.salesforce.com/forums/?id=906F000000091hDIAQ, and I tried to change to SOQL as the last answer suggested but that didn't help. I also added debug statements to the AccountTrigger after line 48, one of which counts the number in the map, and it does match the number in our custom setting. Maybe of note, we have a custom setting from a managed package that has the same name, just with the namespace on the front. But that is not new. What is new is that we were using Rollup Helper and are now trying to implement Declarative Lookup Rollup Summary Tool: https://github.com/afawcett/declarative-lookup-rollup-summaries

Any ideas? Thanks so much to anyone who even looks and considers trying to help!
Alain CabonAlain Cabon
Hi,

Can you post the code of the triggers:1) AssetTrigger: execution of AfterInsert and 2) AccountTrigger: execution of BeforeUpdate ?

System.listexception: row with "duplicate name" is less common than "duplicate id". 

Many people could you if they can read the code otherwise it will be difficult to find a solution.

Class.dlrs.RollupService.Updater.updateRecords: line 1248, column 1:
    try {
                return Database.update(masterRecords, allOrNothing);
   } catch (DMLException e) {

RollupService alone is not enough for helping you.
Michelle GrantMichelle Grant
Thanks! I ended up realizing the offending code was not needed any longer so I just commented it out. Since this is resolved I am moving on to other issues rather than trying to dig further into this one. In the future I'll try to give more information so people can help me find a solution (will just need to make sure it's okay to post our code). I appreciate the reply!
Alain CabonAlain Cabon
Ok. Can you post your applied solution (without code)? There are not so many posts on the forums with "System.listexception: row with duplicate name" (less common than ids) and you could select this post as a "best answer" (it is the solution and your problem is solved).