One simple idea, which is upgradable:
1. Define the global custom field in each module it is needed with same definitions.
2. For each module write a so called logic_hook, to load the values of the global field afer each database retrieve.
Take care that the 3 modules have different module/class names, eg. OpportunitiesVerify, LeadsVerify and ContactsVerify,
Example: global field key_account_c, set in accounts, used in opportunities:
file custom/modules/Opportunities/logic_hooks.php:
PHP Code:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['after_retrieve'] = Array();
$hook_array['after_retrieve'][] = Array(1, 'OpportunitiesVerify', 'custom/modules/Opportunities/OpportunitiesVerify.php','OpportunitiesVerify', 'MyCheckValues');
?>
file custom/modules/Opportunities/OpportunitiesVerify.php:
PHP Code:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class OpportunitiesVerify {
function MyCheckValues(& $focus, $event, $arguments){
// ---------------------------------------------------------------------------------------------
if($event=="after_retrieve"){
// ---------------------------------------------------------------------------------------------
$db = & PearDatabase::getInstance();
$query = "SELECT key_account_c, region_c FROM accounts_cstm WHERE id_c='$focus->account_id';";
$result = $db->query($query, true,"Error fetching key_account_c: ");
$row = $db->fetchByAssoc($result);
if($row != null) {
$focus->key_account_c = $row['key_account_c'];
}
$GLOBALS['log']->DEBUG("KA:".$focus->key_account_c);
}
// ---------------------------------------------------------------------------------------------
// end if logic hook is after_retrieve
// ---------------------------------------------------------------------------------------------
}
//end class OpportunitiesVerify.php
}
?>
In WIKIpages you get more information to logic_hooks.
3. Add the new field to the DetailViews of the 3 modules.
best regards
hk
Bookmarks