AOP. The case creation email is not being sent when relating a case to a contact #4729

Open
opened 2026-02-20 16:22:51 -05:00 by deekerman · 2 comments
Owner

Originally created by @txinparta on GitHub (Feb 9, 2022).

Issue

When a contact is associated to a case, the contact receives case creation, update and case closure emails.
If you do it the other way around, to associate a case to a contact, the inital email is not created.

Expected Behavior

In switchboards, for example, the person who attends the customer usually searches if the contact exists in the application. If it exists, it opens the contact and creates the case in the cases submodule.

The customer should receive the message of the new case opened in his/her name.

Actual Behavior

If we associate a case to a contact the initial email is not sent.

Steps to Reproduce

  1. Prerequisites: an outgoing email and AOP (Advanced Open Portal) enabled.
  2. Load the detail view of a contact.
  3. Go to cases submodule.
  4. Create a new case from cases submodule - or associate an existing one - .
  5. The case is associated with the contact but the initial email is not sent.

Context

Your Environment

  • SuiteCRM Version used: 7.12.1
  • Browser name and version: Firefox Developer Edition Versión 98.02b (64-bit), Chromium version 90.0.4430.212 (Developer Build)
  • Environment name and version: Distrib 10.6.0-MariaDB, PHP 7.3.17
  • Operating System and version: Debian 10 (buster)
Originally created by @txinparta on GitHub (Feb 9, 2022). <!--- Provide a general summary of the issue in the **Title** above --> <!--- Before you open an issue, please check if a similar issue already exists or has been closed before. ---> <!--- If you have discovered a security risk please report it by emailing security@suitecrm.com. This will be delivered to the product team who handle security issues. Please don't disclose security bugs publicly until they have been handled by the security team. ---> #### Issue <!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug --> <!--- Ensure that all code ``` is surrounded ``` by triple back quotes. This can also be done over multiple lines --> When a contact is associated to a case, the contact receives case creation, update and case closure emails. If you do it the other way around, to associate a case to a contact, the inital email is not created. #### Expected Behavior <!--- Tell us what should happen --> In switchboards, for example, the person who attends the customer usually searches if the contact exists in the application. If it exists, it opens the contact and creates the case in the cases submodule. The customer should receive the message of the new case opened in his/her name. #### Actual Behavior <!--- Tell us what happens instead --> <!--- Also please check relevant logs (suitecrm.log, php error.log etc.) --> If we associate a case to a contact the initial email is not sent. <!--- #### Possible Fix --> <!--- Not obligatory, but suggest a fix or reason for the bug --> #### Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug include code to reproduce, if relevant --> 1. Prerequisites: an outgoing email and AOP (Advanced Open Portal) enabled. 2. Load the detail view of a contact. 3. Go to cases submodule. 4. Create a new case from cases submodule - or associate an existing one - . 5. The case is associated with the contact but the initial email is not sent. #### Context <!--- How has this bug affected you? What were you trying to accomplish? --> <!--- If you feel this should be a low/medium/high priority then please state so --> #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: 7.12.1 * Browser name and version: Firefox Developer Edition Versión 98.02b (64-bit), Chromium version 90.0.4430.212 (Developer Build) * Environment name and version: Distrib 10.6.0-MariaDB, PHP 7.3.17 * Operating System and version: Debian 10 (buster)
Author
Owner

@johnM2401 commented on GitHub (Feb 11, 2022):

Hey there,

I'm only able to partly replicate your issues, I'm afraid

On relating an Existing Contact to an Existing Case, The email does seem to send out, on my end.

Do you have all the relevant Email Templates selected in Admin->"Case Module Settings" ?
image

Do you get any errors in the SuiteCRM.log or your PHP error log?


However, I am able to replicate the issue of Cases not sending Emails on creation, so I'll mark this as a "Bug"

@johnM2401 commented on GitHub (Feb 11, 2022): Hey there, I'm only able to partly replicate your issues, I'm afraid On relating an Existing Contact to an Existing Case, The email *does* seem to send out, on my end. Do you have all the relevant Email Templates selected in Admin->"Case Module Settings" ? ![image](https://user-images.githubusercontent.com/13675281/153591956-cd330f14-e15d-4847-ad95-7dc3deb4178f.png) Do you get any errors in the SuiteCRM.log or your PHP error log? <br> However, I *am* able to replicate the issue of Cases not sending Emails on creation, so I'll mark this as a "Bug"
Author
Owner

@txinparta commented on GitHub (Feb 16, 2022):

Hey John,

My mistake, It's true :), relating an existing Case to a Contact sends Ok the email.
(I have Email Templates selected in Admin->"Case Module Settings" )

The problems is as you say only on creation. Since the Case is new "$bean->fetched_row" is false in creationNotify function.

modules/AOP_Case_Updates/CaseUpdatesHook.php:

    /**
     * Called by the after_relationship_save logic hook in cases. Checks to ensure this is a
     * contact being added and sends an email to that contact.
     *
     * @param $bean
     * @param $event
     * @param $arguments
     */
    public function creationNotify($bean, $event, $arguments)
    {
        if (isset($_REQUEST['module']) && $_REQUEST['module'] === 'Import') {
            return;
        }
        if ($arguments['module'] !== 'Cases' || $arguments['related_module'] !== 'Contacts') {
            return;
        }
        if (!$bean->fetched_row) {
            return;    //  ------------ on new cases it falls in this if
        }
        if (!empty($arguments['related_bean'])) {
            $contact = $arguments['related_bean'];
        } else {
            $contact = BeanFactory::getBean('Contacts', $arguments['related_id']);
        }
        $this->sendCreationEmail($bean, $contact);
    }
@txinparta commented on GitHub (Feb 16, 2022): Hey John, My mistake, It's true :), relating an existing Case to a Contact sends Ok the email. (I have Email Templates selected in Admin->"Case Module Settings" ) The problems is as you say only on creation. Since the Case is new "$bean->fetched_row" is false in creationNotify function. modules/AOP_Case_Updates/CaseUpdatesHook.php: ``` /** * Called by the after_relationship_save logic hook in cases. Checks to ensure this is a * contact being added and sends an email to that contact. * * @param $bean * @param $event * @param $arguments */ public function creationNotify($bean, $event, $arguments) { if (isset($_REQUEST['module']) && $_REQUEST['module'] === 'Import') { return; } if ($arguments['module'] !== 'Cases' || $arguments['related_module'] !== 'Contacts') { return; } if (!$bean->fetched_row) { return; // ------------ on new cases it falls in this if } if (!empty($arguments['related_bean'])) { $contact = $arguments['related_bean']; } else { $contact = BeanFactory::getBean('Contacts', $arguments['related_id']); } $this->sendCreationEmail($bean, $contact); } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#4729
No description provided.