Email Logic Hook - After save


I would like to execute a specific code after an email is received. The code parses the email subject and do specific actions. I would like a more custom way than binding the email with a case from the subject ( [Case:XXX] to Case XXX)
However it seems that the hook is never executed.

I use sugar 7.7.2

I added those files and ran "Quick Repair and Rebuild".



   $hook_version = 1;

   $hook_array['after_save'][] = array(
      'Create case or add to case',



   if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

   class email_utils
      function link_to_case($bean, $event )
         $GLOBALS['log']->debug('-- Link to case executed');

         // code goes here




What am I doing wrong here ?

Thank you for your help

  • Hi Bastien,

    I have found two missing pieces in your logichook definition.
    1.Please initialize array variable $hook_array like below.
    2.Please initialize array variable $hook_array['before_save'] like below.

    Logichook definition will look like something below.

    $hook_version = 1;
    $hook_array = Array();
    $hook_array['before_save'] = Array();
    $hook_array['before_save'][] = Array(
    'Store values',
  • Hi Bastien,

    I am not sure what you meant with: "I would like a more custom way than binding the email with a case from the subject ( [Case:XXX] to Case XXX)" as that's just a setting that can be configured out of the box on the Admin area:

    If your needs are around custom case or email (during case creation) assignments/visibility/notification, have a look if this old blog post I wrote still works and if it can help you: Use SugarCRM as your company's Ticketing system | Enrico Simonetti [dot com] 



    Enrico Simonetti

    Principal Technical Advisory Manager

    SugarCRM Inc

  • Hi Enrico, thanks for your input.

    What I want to achieve is to assign an email to a case and link that case to a customer based on the subject (for example the subject contain the customer number). If the email is a reply I want to bind it to the same case. Otherwise I make a new case.

    Email archiving ( ) is close to what I want to do but I don't want to link all emails directly to an account. I want to group emails by conversation (re: ...). Each conversation is bind to a separate case.

    Furthermore the email sender is not the customer so I cannot based the archiving on the sender.

    I am not sure your code suits my need.

Reply Children