Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public static List<Account> getMembersForHousehold(Id householdId){
List<Id> contactIds = new List<Id>();
//collect contactIds (persons) from ACRs
for(AccountContactRelation acr : [SELECT ContactId FROM AccountContactRelation
WHERE AccountId = :householdId
AND Account.RecordTypeId =: myAccountHousholedRecordId]){
//collect accountId from contact
List<Id> accountIds = new List<Id>();
for(Contact con : [SELECT AccountId FROM Contact WHERE Id IN :contactIds]){
List<Account> accounts = [SELECT Id,Name FROM Account WHERE Id IN: accountIds];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment