Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Ok, so it's pretty obvious that these guys are extremely intertwined. The question I have is:

How can I, using the API and PHP, query the lead and account and get the PersonContactId if it is a converted lead? The only thing I have at the moment is the persons Email address and am trying to minimize queries as much as possible. i know I could just run a retrieve once I query the lead and get the ConvertedAccountId, but my goal is to minimize as much as possible. Is this even possible given the two relationships? Any advice on this would be awesome. Thanks!

share|improve this question
add comment

1 Answer 1

You could query the Lead object and then use the child-to-parent relationship to also pull back details of the person account in the same query.

E.g. Get the converted Account name.

Select Id, ConvertedAccountId, ConvertedContactId, IsConverted, ConvertedDate, Lead.ConvertedAccount.Name from Lead where IsConverted = true

You will want to add something like Lead.ConvertedAccount.PersonContactId to the query. With Person accounts enabled I believe you could also use the ConvertedContactId (ConvertedContact relationship Name) as there will be a one to one mapping between the Contact and the Account.

See Relationship Queries for documentation on querying between objects in SOQL.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.