Created
September 2, 2019 16:28
-
-
Save rickschmidt/d3e3f076030386f7f1727036111f7824 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]){ | |
contactIds.add(acr.ContactId); | |
} | |
//collect accountId from contact | |
List<Id> accountIds = new List<Id>(); | |
for(Contact con : [SELECT AccountId FROM Contact WHERE Id IN :contactIds]){ | |
accountIds.add(con.AccountId); | |
} | |
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