I have two objects, Financial_Account and Client; they are connected with master-detail relationships to Client_Financial_Account_Relationship object. In a trigger on 'Financial_Account' I want to compare a field from Financial_Account and one on Client. My guess is to query for the junction object where Financial_Account_Id is equal to the one in my loop. Am I right there, is this the best way ? If so then how can do I get a list of all the associated records ?
I'm thinking something like this:
public static void checkOfferEnrollmentDateChange(List<Financial_Account__c> financialAccounts) {
List<Client_Financial_Account_Relationship__c> relatedClients =
[Select ID,Customer__c,Financial_Account__c From Client_Financial_Account_Relationship__c Where IN :financialAccounts];
}