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
vasuvasu 

Duplicate Lead on existing records

I want to find duplicate records on existing leads I have 1lac records on leads , I used select query statement it return List Object but it store only 1000 records , i compared these records with existing records

Below my code:

 

List<Lead> ld = [select Name,Email from Lead];

 

for(Integer i =0;i<ld.size();i++){

 

    List<Lead> lds =[Select Name,Email from Lead where Email=:ld[i].Email];

 

}

 

 Is there chance to write join query on same lead object to get duplicates , if have more then 1000 duplicate records ........?

 

 

Thanks

Vasu

jkucerajkucera

What's "1lac records"?  Is this a custom object?

 

When do you want this code to run?  Button click, upon insert or update, or some other time?


Triggers are the way to go for insert & update.  Batch Apex is the way to go for button click.  I'm pretty sure there's some free find dupes apps on the appexchange that prevent creation of 2nd lead with the same email.