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
RudrAbhishekRudrAbhishek 

trigger to create duplicate lead

Hi All,

need to write a new trigger on lead which will check for ‘Open-Not Contacted’ Leads and then creates a duplicate entry of the same lead but with status as ‘Working – Contacted’, rest all information will be the same.

Thanks,

RudrAbhishek

Satish_SFDCSatish_SFDC
See if this works.

<pre>
trigger LeadTrigger on Lead (before insert) {
    List<Lead> lstLeads = new List<Lead>();
    for(Lead l : Trigger.new){
        if(l.Status=='Open'){
            lstLeads.add(l) ;
        }       
    }
   
    List<Lead> lstDupLeads = lstLeads.deepClone(false, true, false);
    for(Lead l : lstDupLeads){
        l.Status='Contacted';
    }
    insert lstDupLeads;       
}
</pre>

Regards,
Satish Kumar
kantravikantkantravikant
I think you should create a button on lead ,onclick which will check duplicate if not than create.