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
AbAb 

SOQL for finding Lead from Contact

Hello,

When a lead is converted, how can i find out the lead whcih is associated with the Contact.
I want t find out the leadfrom the contact.

Wthank you for suggestion
Best Answer chosen by Ab
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

You could do a SOQL query on your closed Leads. The following query will provide you a list of all Accounts and Contacts that originated from a converted Lead. You could filter it on specific Account Ids, if necessary.
Get all converted Accounts and Contacts:
 
SELECT Id, ConvertedAccountId, ConvertedContactId FROM Lead WHERE Status = 'Qualified'

To find the original Lead for a specific Contact, use below query:
 
SELECT Id FROM Lead WHERE ConvertedContactId = 'Enter_Contact_Id'

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

sfdcMonkey.comsfdcMonkey.com
try this :
SELECT ConvertedAccountId,ConvertedContactId,Id FROM Lead Where ConvertedContactId = '003XXXXXXXXXXXXXXX'

Thanks 
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

You could do a SOQL query on your closed Leads. The following query will provide you a list of all Accounts and Contacts that originated from a converted Lead. You could filter it on specific Account Ids, if necessary.
Get all converted Accounts and Contacts:
 
SELECT Id, ConvertedAccountId, ConvertedContactId FROM Lead WHERE Status = 'Qualified'

To find the original Lead for a specific Contact, use below query:
 
SELECT Id FROM Lead WHERE ConvertedContactId = 'Enter_Contact_Id'

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer