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
JoannaAtMaritzJoannaAtMaritz 

Need advice regarding how to proceed with Lead Management

My company is designing how we want to implement Leads/Campaigns.  We're running into some issues regarding how to implement the business requirements technically within Salesforce.  We're planning on implementing Web-to-Lead, in which users requesting information from us online (e.g.. when downloading a webcast) can be tracked in the system as Leads.

 

However, rather than simply having this add as a Lead, they want to go further.  If the Lead has the same e-mail address as an already existing contact in SFC, they want to send an alert to the contact's owner, add an activity to the contact, and then close the Lead.

 

Most of this seems like Workflow (e-mail alerts, adding the task, field update to close the lead).  But, I couldn't see how to create the Workflow Rule to check to search contacts based on e-mail address.  And, if one is found, to add the task and send the e-mail alert based on that contact.  Plus, what if there are multiple contacts with that same e-mail address?  Any advice?  Can this be done via Workflow? 

 

Or do I have to try to figure out how to do this via a trigger?  If I have to go the trigger route, is there any kind of sample trigger code regarding searching contacts by e-mail address, sending e-mail alerts, and adding an activity to a contact? 

 

Thanks so much.  Any advice is appreciated.

 

 

jkucerajkucera

Trigger is the way to go to check for dupes on Contact.  You could do something like this:

 

1) Trigger fires after insert on Lead

2) If dupe contact or lead found, update custom field Dupe_Found__c =True

3) Workflow email alert fires to the Lead/Contact owner when Dupe_Found__c=True

4) Workflow field update fires updating Dupe_Found__c to False (in case other dupes found in the future)

 

 

I don't have time to write much syntax today, but the general stuff you wnat to do:

1) Loop through the Leads in Trigger.new

2) Add the email addresses to a Set of emails

3) Query Contacts using the set as criteria: List<Contact> Contacts =[Select ID, Dupe_Found__c FROM Contact WHERE email IN: emails LIMIT 1000];

4) Close the 1st loop, then Loop through contacts found, setting Dupe_Found__c = True

5) Repeat if desired checking leads for dupes