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

how to create a task assigned to leadowner when the duplicate lead is found.

Hi ,

Im using trigger and class to check the duplicate lead using email and phone.It is working.When a lead exists a task should create under original lead and assigned to leadowner.How can i achieve this?
Shravan Kumar 71Shravan Kumar 71
Hello Devmen,

Once you find a duplicate lead, are you updating any field on Lead indicating it as duplicate lead. You can use the below in your existing code to create the task :

 List <Lead> duplicateLead = [SELECT ID, Status FROM Lead WHERE Status = 'Duplicate']; 
  List <Task> taskToInsert = new List<Task> ();
    for (Lead l : duplicateLead) {
        Task t = new Task ();
        t.Subject = 'Duplicate Lead';
        t.WhoId = l.Id;
  insert taskToInsert;

Let me know how it goes.