+ Start a Discussion

How are lead, contact, opportunityn, account are linked technically(field ?)


I have converted my lead to Oportunity, contact and account.

How are they interlinked, If i need to query each of them from the others, what is the SOQL query, i can use

Thank in advance
Best Answer chosen by Sandrine
Hi Sandrine,

When you convert a lead record then It creates Account, Contact and Optionally Opportunity (Deal is optional, based on the checkbox when you click on the Lead Convert button).

Account & Contact is having a kind of Special lookup relationship in which on the UI they are acting as a lookup relationship(meaning the account is not mandatory on Contact) however they support the cascade-delete option in the backend(meaning if you delete an Account and if there are any associated contacts then It will delete all the contact records). Also you can't create a roll up summary fields on the Account for any roll up operation from the Contact.

Account & Opportunity is also having a kind of Special  Master-detail relationship. The Account Name field is not required while creating new Opportunity on the UI however It supports cascade-delete option and also can be roll up on Account.

You can use Relationship Queries(Joins) to fetch records - 
1. Account with Contact -
SELECT Id, Name,(SELECT Id, Lastname FROM Contacts) FROM Account
2.Account with Opportunity -
SELECT Id, Name,(SELECT Id, Name, Closedate, Stagename FROM Opportunities) FROM Account
Hope this answers your question. Please post here if you have any further doubts.

Happy Coding!