1

We're trying the inbound e-mail to activity functionality and it works fine.

The only limitation until now is that the 'source' and 'assigned to' contact seems to be the same.

We need to have a process that adds an activity assigned to 'C', created by 'A' with contact 'B'.

Is this possible out of the box? Would you use a CiviRule to change assignee?

(we've been through documentation and SE and couldn't find such a situation, that seemed at first obvious to me)

1 Answer 1

1

Would https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_emailProcessor/ work? It will let you update the assignee on the activity after it gets saved.

e.g.

function myextension_civicrm_emailProcessor( $type, &$params, $mail, &$result, $action = null ) {
  if ($type != 'activity') {
    return;
  }
  $contact_id = 36377; // this is contact C
  $params = array(
    1 => array($contact_id, 'Integer'),
    2 => array($result['id'], 'Integer'),
    3 => array(CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Assignees'), 'Integer'),
  );
  CRM_Core_DAO::executeQuery("UPDATE civicrm_activity_contact SET contact_id = %1 WHERE activity_id = %2 AND record_type_id=%3", $params);
  // or use api if preferred
}
1
  • thanks Dave, this means I don't need to dig further in some hidden front setting. We'll use this hook instead. Jan 18, 2022 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.