I'm trying to create a Custom Field in SugarOS 6 to store Middle Names. Designing and implementing the field in EditView was easy enough with the Studio. But I'm stuck when it comes to displaying the concatenated name parts in DetailView (i.e. Salutation + First Name + Middle Name + Last Name).
Foraging through the Sugar Forums got me to this thread which describes a way it can be done. I've implemented the code given there in the form of a Sugar logic hook that utilizes the after_retrieve hook that is called upon the loading of a record.
Here's my hook code:
$hook_array['after_retrieve'] = Array();
$hook_array['after_retrieve'][] = array(
100,
'set_full_name',
'custom/modules/Leads/leads_custom_logic.php',
'LeadsCustomLogic',
'setFullName'
);
And here's the function that is being called:
function setFullName( &$focus, $event, $arguments ) {
$name = $focus->salutation . ' ' .
$focus->first_name . ' ' .
( $focus->middle_name_c ? ( $focus->middle_name_c . ' ' ) : '' ) .
$focus->last_name;
$focus->name = $name;
$focus->full_name = $name;
// echo $focus->full_name;
}
The hook and the called code seems to work fine and if I uncomment the last line (echo) the full name is dumped all over the screen (wherever this function is called). However, it's not displaying where it's actually supposed to, i.e. the row in the DetailView screen where the full name appears.
Any ideas?
Thanks, m^e