AnsweredAssumed Answered

Logic hook not working as intended (and can't find debug information)

Question asked by Sil68 Sil68 on May 25, 2015

I'm in the process of creating a logic hook for pulling some contact information from the parent record (Contacts) and display these in custom fields in the child record (Tasks)

Try as I might, scouting the Web, I can't get the hook working properly!

Under "custom/modules/Tasks" I've create a file called "logic_hooks.php"

<?php// $Id$
$hook_version = 1;
$hook_array = Array(); 
// debug
$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
$GLOBALS['log']->debug("Task: logic hook invoked");  
// position, file, function
$hook_array['after_retrieve'] = Array();
$hook_array['after_retrieve'][] = Array('1', 'contact_info', 'custom/modules/Tasks/hooks/contact_info.php','contact_info_class', 'contact_info_method');
and under "custom/modules/Tasks/hooks" I've create a file called "contact_info.phplogic_hooks.php"

class contact_info_class {   // retrieve contact information from parent record   function contact_info_method($bean, $event, $arguments) {    // debug    $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');    $GLOBALS['log']->debug("Tasks: contact_info_method called for event ".$event . "(BeanID: " . $bean->id . ")");        // fetch data    if ($bean->fetched_row['id'] != $bean->id) {     // load Task     //$bean = BeanFactory::getBean('Tasks', $id);          // check if relationship is loaded     //if ($bean->load_relationship('contact_tasks_parent'))     if ($bean->load_relationship('contact_tasks')) {      // fetch related beans       //$relatedBeans = $bean->contact_tasks_parent->getBeans();      $relatedBeans = $bean->contact_tasks->getBeans();            $parentBean = false;      if (!empty($relatedBeans)) {       // order the results       reset($relatedBeans);              // first record in the list is the parent       $parentBean = current($relatedBeans);              // retrieve data from parent bean       $bean->contact_phone_c = $parentBean->phone_work       $bean->contact_primary_email_c = $parentBean->email1      }     }    }   } // contact_info_method  } // contact_info_class  ?>
                                                                                                               With this hook in place I can create new tasks without any problem at all, but when opening up an existing one, I'm receiving a message, reading

There was an error processing your request, please try again at a later time.

Being completely new to SugarCRM (btw. 6.5.20 CE it is I'm dealing with), I've got not the faintest idea as what is going wrong here.

I also cannot find any of the debug messages which are supposed to be written somewhere to.