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
Mike Dwyer 9Mike Dwyer 9 

How can I resolve a duplicate Name value in a custom object?

This may be buried somewhere in the forum, but I cannot tease out the answer to my situation. I apologize for any - uh - duplication.

We have a custom sObject in our org. Records created in 2015 have been found to have a duplicate Name value. That is, two distinct records, with different Id values on each, both have the same Name value. Name, for what it's worth, is an AutoNumber field.

I can query both records into the Developer Console query results, but I cannot change the Name value. How can I make the Name as unique as the Id?

Second question: How can I find other similar duplicates? In SQL, I would use SELECT Name, Count(Id) FROM LOIS_Offender__c GROUP BY Name ORDER BY Count(Id) DESC, but SOQL says, "field 'Name' can not be grouped in a query call". 
Steven NsubugaSteven Nsubuga
Temporarily change the type of the Name field to Text, then edit the record. Then change it back to AutoNumber.

I suggest using an ordinary query, order by name and then process the results, perhaps using batch apex.
mritzimritzi
When you use COUNT, you can't use any other field, and the parameter you pass is automatically used to group data
Select COUNT(Website) From Account
will tell you, how many Unique websites are there in Account object in your org
Select Website From Account
will tell you, total number of records in Account
(Run these in developer console, after changing field Api names & object api name)

------------------------------------------------------------------------------------
You'll have to run report to see duplicate values (given that you have admin proviledges, access to all records in the object)

Create report on your custom Object
Created Date Range -> All time, Show -> All Records
Just keep relevant fields in the table
Click on Name field, Select Group By this field
Run report.

I did it for checking duplicate websites in Account

duplicate website report

All the records with hyperlink will be listed in the table below (grouped by Website).
Apparently, I have 517 records with Website = NULL & 3 records with website www.uos.com
report1

If this helps solve your problem, please mark this as BEST ANSWER
 
Mike Dwyer 9Mike Dwyer 9
The first answer helped with the first question.
Neither answer is a reasonable method for solving the second question. It is irritating that with all the supposed power of "no code" Salesforce, that a simple SQL query cannot be performed without external processing.