SELECT contact.id as id,
contact.sort_name as sort_name
FROM civicrm_contact contact
-INNER JOIN civicrm_activity_assignment assignment ON ( assignment.assignee_contact_id = contact.id )
+INNER JOIN civicrm_activity_contact assignment ON ( assignment.contact_id = contact.id AND record_type = 'Assignee' )
INNER JOIN civicrm_activity activity ON ( activity.id = assignment.activity_id )
INNER JOIN civicrm_survey survey ON ( activity.source_record_id = survey.id )
{$whereClause}";
LEFT JOIN civicrm_entity_file ef on ef.entity_table = "civicrm_activity" AND ef.entity_id = ca.id
LEFT OUTER JOIN civicrm_option_group og ON og.name="activity_status"
LEFT OUTER JOIN civicrm_option_value ov ON ov.option_group_id=og.id AND ov.name="Scheduled"
- LEFT JOIN civicrm_activity_assignment caa
- ON caa.activity_id = ca.id
- LEFT JOIN civicrm_contact acc ON acc.id = caa.assignee_contact_id ';
+ LEFT JOIN civicrm_activity_contact caa
+ ON caa.activity_id = ca.id AND caa.record_type = "Assignee"
+ LEFT JOIN civicrm_contact acc ON acc.id = caa.contact_id ';
$where = 'WHERE cca.case_id= %1
AND ca.is_current_revision = 1';