I am having problems creating a SOQL query over my 3 objects.
Contact, Patient and Disease
Patient and Disease are in a Master Detail relationship, where Disease is the Master
Contact is a Lookup field in Patient.
So, the query that I need is: Select Id from Contact, where patient is that contact and has disease x
I need this query to populate the list targetObjects in this code:
List <Id> targetObjectIds = new List <Id> ();
List <Contact> targetObjects = new List <Contact> ();
targetObjects = [SELECT Id FROM Contact];
for(Contact cnt : targetObjects) {
targetObjectIds.add(cnt.Id);
}
Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
mail.setTargetObjectIds(targetObjectIds);
Tia.