You need to sign in to do that
Don't have an account?
SV M
Contacts created by lead conversion
Hi, I was stuck at a point where I need to get the contacts created by lead conversion. Can someone tell me how to query those contacts when a lead is converted...
I am new to salesforce so please help me do this.
Thanks in advance...
I am new to salesforce so please help me do this.
Thanks in advance...
You can try below query.
SELECT Id,Name, ConvertedContactId FROM Lead WHERE ConvertedContactId != null
Below are few examples for your reference.
https://www.redargyle.com/blog/lead-field-history-on-a-contact-record/
https://gist.github.com/aldoforce/0dc5bec35f6d1d06867b
You can create a Report on Converted Leads.
https://help.salesforce.com/articleView?language=en_US&type=1&mode=1&id=000329521
Hope above information was helpful.
Please mark as Best Answer so that it can help others in the future.
Thanks,
Vinay Kumar
//Batch Class
global class LeadConversionEmail implements Database.Batchable <sObject>, Database.Stateful{
//public List<Contact> conList {get;set;}
global Database.QueryLocator start(Database.BatchableContext BC) {
String query = 'SELECT Id, LeadSource, ConvertedDate FROM Lead WHERE ConvertedContactId != NULL';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, Lead[] scope) {
List<Contact> conList = new List<Contact>();
for(Lead ld : scope) {
conList.add([SELECT FirstName, LastName
FROM Contact
WHERE Id IN (SELECT ConvertedContactId FROM Lead)]);
}
}
global void Finish(Database.BatchableContext BC) {
messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String body = 'FirstName ' +conList.FirstName+ 'LastName ' +conList.LastName+ 'done';
}
}
I am getting errors at body saying Variable does not exist. Can you help me resolve the problem and how to send email to contact owner.
Thanks in Advance.
Please review below are working example snippet.
https://www.salesforcetutorial.com/sending-email-to-all-contacts-of-an-account/
https://www.cloudforce4u.com/2013/07/send-email-in-apex-salesforce.html
Thanks,
Vinay Kumar