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!


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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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