Given a contact ID, I'm looking to get all the contact's information as well as their associated account name (if they have one associated account) or the name of the direct account if they have multiple associated accounts.

The following works if the contact has an associated Account, but isn't handling the case where the contact has no account, and I'm not sure if there's a case of a contact having a single account which isn't direct.

SELECT contactID, contact.FirstName, contact.LastName, Account.Name, contact.Phone, contact.Title, contact.Email, contact.Contact_Type__c, contact.Inactive__c, acr.isdirect FROM AccountContactRelation acr where (contactid = '{markId}' and isdirect = true)

1 Answer 1


The AccountContactRelation (ACR) sObject is a junction object that resolves the many to many relationship of many Contacts being connected to many Accounts. In order for the junction object to exist, it needs to be connecting a Contact to an Account. If a Contact has no Account, the junction object would not have been created in the first place. So, in answer to your question, you don't have to worry about a Contact having no Account -- the ACR would not exist in that case.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .