+ Start a Discussion

Exception on retrieving Custom Settings - Row with duplicate Name at index 1


We have a managed package which uses Custom Settings and we are getting the exception "Row with duplicate Name at index 1" when the code is trying to pull back all of the settings - here is the code:
List<Our_Custom_Setting__c> settings = Our_Custom_Setting__c.getall().values();

We have seen there was a similar issue on sandboxes before but this is in a production org.

How would a duplicate have gotten in? Any idea how we can fix this? 
Hi Anam,

Not sure if I am honest but perhaps during the instal of the managed package, it is creating a dupliacte custom setting? I would have thought this to be unlikly as the managed package settings are typically named quite well. In any case, you will have to remove the dupliacte otherwose you will continue to face this issue.

Please remeber to mark this thread as solved  with the answer that best helps you.

Kind Regards
I'm also having this issue.  It's definitely a bug.  There's no easy work around, you have to do a SOQL query determine which record(s) needs to be deleted and then delete them after copying the values to the one you're going to preserve.
As a clue, I seem to be getting this when I have batch processes interacting with my custom settings.