How to reopen a case automatically when a new email is received(using Process Definitions)?

Hi,

I'm using Sugar 8.0.3 Enterprise, how can i re-open an existing  closed case(Status: Closed) when a new email imported via email to case functionality has the matching Case Number[Case Macro]  on the subject ?

I note that Emails is not a module that can be configured for the Process Definitions(SugarBPM) in Sugar 8x , however it is on Sugar 10x


Regards,

Vijay

Parents
  • Personally,

    We did a logic hook in the Emails module which triggers when an email is related to a Case.

    We do a lot more than what's below, check for inbound vs outbound, check if it was from an email in our domain or not, check which department it's assigned to (tech support vs info vs documentation feedback etc...), verify that it was not closed as Spam etc... but I boiled it down to basics below, you can add your own logic to it.

    $hook_array['after_relationship_add'][] = array(1,'email_case_relationship','custom/modules/Emails/email_case_handling.php','EmailCaseHandling','update_on_relationship',);

    <?php
    class EmailCaseHandling
    {
       // If the Email is inbound and RELATED to a case, reopen the case and notify the assigned user
       function update_on_relationship ($bean,$event,$arguments){
          //bean = Email
          //case retrieved from related_id
          if ($arguments['related_module'] =='Cases'){
             $case = BeanFactory::retrieveBean('Cases', $arguments['related_id']);
             if($bean->type == 'inbound'){
                //case FROM  customer (not from an internal address)
                $case->status = 'Open';
                $case->save();
                //notify assigned users using custom script that composes the email and sends it via Mailer factory
                //we use the same notify_assigned_user to send notifications about various events on the case and found it practical to have reuseable code. 
                //Mailer factory https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_12.0/Architecture/Email/Mailer_Factory/
                   notify_assigned_user($case, $bean, "Inbound Email on Closed Case");
             }
          }
       }
    }
    ?>

    FrancescaS

Reply
  • Personally,

    We did a logic hook in the Emails module which triggers when an email is related to a Case.

    We do a lot more than what's below, check for inbound vs outbound, check if it was from an email in our domain or not, check which department it's assigned to (tech support vs info vs documentation feedback etc...), verify that it was not closed as Spam etc... but I boiled it down to basics below, you can add your own logic to it.

    $hook_array['after_relationship_add'][] = array(1,'email_case_relationship','custom/modules/Emails/email_case_handling.php','EmailCaseHandling','update_on_relationship',);

    <?php
    class EmailCaseHandling
    {
       // If the Email is inbound and RELATED to a case, reopen the case and notify the assigned user
       function update_on_relationship ($bean,$event,$arguments){
          //bean = Email
          //case retrieved from related_id
          if ($arguments['related_module'] =='Cases'){
             $case = BeanFactory::retrieveBean('Cases', $arguments['related_id']);
             if($bean->type == 'inbound'){
                //case FROM  customer (not from an internal address)
                $case->status = 'Open';
                $case->save();
                //notify assigned users using custom script that composes the email and sends it via Mailer factory
                //we use the same notify_assigned_user to send notifications about various events on the case and found it practical to have reuseable code. 
                //Mailer factory https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_12.0/Architecture/Email/Mailer_Factory/
                   notify_assigned_user($case, $bean, "Inbound Email on Closed Case");
             }
          }
       }
    }
    ?>

    FrancescaS

Children
No Data