
Can I run a query on Contacts that is searching for attributes in the Accounts to which the contacts are linked? Put another way, I want to search for everyone associated with an account that has certain account field attributes.
For example, I have a custom Accounts field for "client?", a checkbox or yes/no field. Can I run a query showing me all the contacts associated with accounts that are flagged as client accounts?
Thanks!
3 个回答
The standard report "Contacts & Accounts" would have all this information available for you!
Unless you're specifically looking for a query as you were asking for, in which case relationship queries are how you would handle this: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_query_using.htm#.sforce_api_calls_soql_relationships_query_using
The first example on that page is actually doing exactly what you want and pulling some account data into a contact query.