I’m using SalesForce v 33.0 and I am trying to write a single query that, given a number of account ids, can identify the team members (their first name, last name, and email) whose roles are designated as “Manager”. I would like to figure out with which accounts these team members are associated. I have this

Select Id, AccountId From AccountTeamMember WHERE TeamMemberRole = 'Manager' and AccountId in ('001F000001INbk8', '001F000001INbk7', ...) 

but I am stuck because I don’t know how to associate the AccountTeamMemember object back to a Contact object where the first name, last name, and email data live.

I will eventually use the results of this query with the Java API.


AccountTeamMembers are related to User objects, not contacts. In SOQL you can access lookup relationships via dot-nation as fields to return in your statement. For your requirements you can do this like:

Select Id, AccountId, User.FirstName, User.LastName, User.Email From AccountTeamMember
WHERE TeamMemberRole = 'Implementation Manager' 
and AccountId in ('001F000001INbk8', '001F000001INbk7', ...)

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.