function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DmitriEchoLaneDmitriEchoLane 

SOQL Help: Bring all Contacts for (Accounts that own Asset = X)

I am having difficulty creating a SOQL query that brings the list of all contacts associated with Accounts that own a certain Asset.
The query should bring ALL contacts under the Account - regardless if the the contact is linked directly to that specific Asset or not.


Is this possible to do in a single SOQL query?


Thanks a lot,
Dmitri
RickyGRickyG
Dmitri -

I think you will have to implement this with two SOQL passes - the first to select Accounts that own the Asset(s), and the second to bring back all the Contacts for the Account.  Depending on the number of Accounts that are going to turn up, it might make sense to store the Account ID in another object and use that to join to the Accounts when you retrieve the Contacts.

Hope this helps.
NikkiSmith1NikkiSmith1

I'm trying to accomplish the same thing; however, not only do I need to know if these contacts own Asset = X, I also need to make sure they do not own Asset=Y...

 

Any ideas on how to accomplish this?