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
kondru sampreethkondru sampreeth 

i got an error "line No 5 expecting a right parentheses, found ';'--- trigger line No 12 same error in class, how to resolve this

please need your help

 line No 5 expecting a right parentheses, found ';'--- trigger
line No 12  same error in class
--------------------------------------------------------------

trigger FindDupesonLead on Lead (before insert) {
 for (Lead myLead : Trigger.new) {
    if (myLead.Email != null) {
      List<contact> dupes = [SELECT Id FROM Contact WHERE Email = :myLead.Email];

//below line getting an error
      if (dupes != null &amp;&amp; dupes.size() &gt; 0) {
        String errorMessage = 'Duplicate contact found! ';
        errorMessage += 'Record ID is ' + dupes[0].Id;
        myLead.addError(errorMessage);
      }
    }
  }
}
---------------------------------------------------------
public class FindDupesonLead {
    public static List<account> mergeDupeContactsInAnAccount(List<account> accList) {
 
        // Create a set of duplicate contacts that
        //  we will delete later. We use a set because it has the contains() method
        Set<contact> duplicates = new Set<contact>();
 
        // For each account, we will loop over every contact to find a dupe
        for (Account a : accList) {
             //below  line i am getting an error
     
            // There needs to be at least 2 contacts to have a dupe
            if (a.Contacts != null &amp;  a.Contacts.size() > 1) {
 
                // Iterate across the account's contacts to find dupes
                for (Contact outerContact : a.Contacts) {
             
                    // Skip this contact if it has been identified as a dupe
                    if (duplicates.contains(outerContact)) { continue; }
             
                    // Iterate again though the contacts to find a match by email or name
                    for (Contact innerContact : a.Contacts) {
                 
                        // Skip this contact if it has been identified as a dupe
                        if (duplicates.contains(innerContact )) { continue; }
                 
                        // Since the original contact is in this list, make sure we don't match it
                        if (outerContact.Id != innerContact.Id) {
                     
                            // Check for a match by email
                            if (outerContact.Email != null &amp;&amp; outerContact.Email.equals(innerContact.Email)) {
                                duplicates.add(innerContact);
                                continue;
                            }
                         
                            // Now check for a match by name
                            if (outerContact.FirstName != null &amp;&amp; innerContact.FirstName != null) {
                                String outerContactName = outerContact.FirstName + outerContact.LastName;
                                String innerContactName = innerContact.FirstName + innerContact.LastName;
                                if (outerContactName.equals(innerContactName)) {
                                    duplicates.add(innerContact);
                                    continue;
                                }
                            }
                         
                        }
                     
                    }
                 
                }
             
            }
         
        }
     
        // Delete dupes
       // if (duplicates.size() &gt; 0) {
           // List<contact> duplicatesList = new List<contact>();
          //  duplicatesList.addAll(duplicates);
          //  delete duplicatesList;
        }
     
        return accList;
    }

}
Himanshu ParasharHimanshu Parashar
Hi,

Please Try following code for trigger
 
trigger FindDupesonLead on Lead (before insert) {
 for (Lead myLead : Trigger.new) {
    if (myLead.Email != null) {
      List<contact> dupes = [SELECT Id FROM Contact WHERE Email = :myLead.Email];

        //below line getting an error
      if (dupes != null && dupes.size() > 0) {
        String errorMessage = 'Duplicate contact found! ';
        errorMessage += 'Record ID is ' + dupes[0].Id;
        myLead.addError(errorMessage);
      }
    }
  }
}

 
Himanshu ParasharHimanshu Parashar
and replace as shown below for class at line no 12 
 
&amp;    &

Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.