
Originally Posted by
andopes
Yes, the logic_hook process_record is triggered by either ListView and Subpanel.
Indeed this should work as written in DevGuide, etc. But I couldn't manage to fire process_record hook. In my case I need to display releted module field value in ListView mainly and DetailView. I added custom varchar field to Contacts module named 'speciality_c'. In my scenario if Meeting is related to Contact through existing Flex Relate field that I want to display that 'speciality_c' value in Meetings ListView and DetailView.
So, I created custom/Extension/modules/Meetings/Ext/Vardefs/contact_speciality.php to add 'non-db' field:
PHP Code:
<?php
$dictionary['Meeting']['fields'][] = 'contact_speciality';
$dictionary['Meeting']['fields']['contact_speciality'] = array(
'name' => 'contact_speciality',
'source' => 'non-db',
'type' => 'varchar',
'len' => 255,
'vname' => 'LBL_CONTACT_SPECIALITY',
);
?>
Then in custom/modules/Meetings/logic_hooks.php define the hook:
PHP Code:
<?php
$hook_version = 1;
$hook_array['process_record'] = array();
$hook_array['process_record'][] = array(10, 'Get Contact speciality', 'custom/modules/Meetings/logic_hooks/get_contact_speciality.php', 'getContactSpeciality', 'getContactSpeciality');
?>
And at last the hook itself in custom/modules/Meetings/logic_hooks/get_contact_speciality.php :
PHP Code:
<?php
if(!defined('sugarEntry')) define('sugarEntry', true);
require_once 'modules/Contacts/Contact.php';
class getContactSpeciality {
function getContactSpeciality(&$bean, $event, $arguments) {
if ($bean->parent_type == 'Contacts') {
$contact = new Contact();
$contact->retrieve($bean->parent_id);
$bean->contact_speciality = $contact->speciality_c;
} else {
return;
}
}
}
?>
Of course, detailviewdefs.php and listviewdefs.php were modified as well to display 'contact_speciality' value. But nothing happens to make me happy.
I tried to debug using $GLOBALS['log']->debug() but it seems that hook doesn't fire at all. (BTW, where in code tree should I place breakpoint to debug logic hook in IDE like Eclipse or NetBeans? I set breakpoint in file above, start debug session, but it seems that Sugar bypasses breakpoint. Developer mode enabled, xdebug setup properly.)
Are there any obvious mistakes in my code that don't let process_record fires? My before_save hooks works exactly as needed.
P.S. I'm on SugarCE 6.0.0
Bookmarks