Hello,
For every Case I can relate more than one Contacts and this is convenient in many cases.
My problem is that when I add an update for a Case with more than one Contacts, the email (notification for the Case update) goes to only one of the related Contacts.
This seems like a bug. I would like to find a work around that, ideally, could also be committed to the code base to fix the bug.
Which file controls who receives mail notifications for Case updates and Case closures ?
Thanks in advance for any ideas.
Regards,
George
I think I made some progress on this and I’d like to share.
After searching a little I think that the solution is somewhere in the directory
modules/AOP_Case_Updates/
and probably specifically in
modules/AOP_Case_Updates/AOP_Case_Updates.php
36 function save($check_notify = false){
37 global $current_user, $sugar_config;
38 parent::save($check_notify);
39 $email_template = new EmailTemplate();
40 if($_REQUEST['module'] == 'Import'){
41 //Don't send email on import
42 return;
43 }
44 $signature = array();
45 $addDelimiter = true;
46 $aop_config = $sugar_config['aop'];
47 if(!empty($this->contact_id)){
48 $emails = $this->getEmailForUser();
49 if($aop_config['user_email_template_id']){
50 $email_template->retrieve($aop_config['user_email_template_id']);
51 }
52 $addDelimiter = false;
53 }elseif($this->assigned_user_id && !$this->internal){
54 $emails = $this->getEmailForContact();
55 if($aop_config['contact_email_template_id']){
56 $email_template->retrieve($aop_config['contact_email_template_id']);
57 $signature = $current_user->getDefaultSignature();
58 }
59 }
60
61 if($emails && $email_template){
62 $GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
63 $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter);
64 }
65 }
What is the type of the $emails variable? Can it contain more than one emails?
Any ideas?
Thanks in advance.
Regards,
George
Hello dear community members,
I think I found a solution (for now it works for me) but I would like a second opinion from anybody who detects any mistakes in my proposed solution. I would also like to have some info on how to make ‘upgrade safe’ the proposed changes and on how I can submit my changes (if they are accepted) to be included in SuiteCRM’s code base.
Here are my changes:
In modules/AOP_Case_Updates/AOP_Case_Updates.php
}elseif($this->assigned_user_id && !$this->internal){
54 $emails = $this->getEmailForContacts();
55 if($aop_config['contact_email_template_id']){
56 $email_template->retrieve($aop_config['contact_email_template_id']);
57 $signature = $current_user->getDefaultSignature();
58 }
59 }
I replaced getEmailForContact() with getEmailForContact[color=#ff0000]s/color which is a customized function based on getEmailForContact()
Here is the original getEmailForContact()
private function getEmailForContact(){
$addresses = array();
$contact = $this->getContact();
if($contact){
$addresses[] = $contact->emailAddress->getPrimaryAddress($contact);
}
return $addresses;
}
and
Custom getEmailForContact[color=#ff0000]s/color
private function getEmailForContacts(){
$addresses = array();
$contacts = $this->getContacts();
foreach ($contacts as $contact){
if($contact){
$addresses[] = $contact->emailAddress->getPrimaryAddress($contact);
}
}
return $addresses;
}
Also
Original getContact()
public function getContact(){
$case = $this->getCase();
if($case){
$contacts = $case->get_linked_beans("contacts","Contacts");
return $contacts[0];
}
return null;
}
Custom getContact[color=#ff0000]s/color
public function getContacts(){
$case = $this->getCase();
if($case){
$contacts = $case->get_linked_beans("contacts","Contacts");
return $contacts;
}
return null;
}
Please share any related comments you may have.
Thanks in advance.
Regards,
George
A problem with my solution is that the email template used for the notifications sent to the related contacts, uses the data of the contact that was related last with the Case. Maybe, I should send a separate email for every contact. When I fix this I’ll post again.
If you also have any ideas on how to fix this, please share. Also please take a look at the othe questions in my previous post.
Thanks,
George