3

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

miCRoSCoPiC_eaRthLinG
  • 2,910
  • 4
  • 40
  • 56

1 Answers1

1

maybe just change detailview.php and add the following to your full name field defs

'customCode' => '{$fields.salutation.value} {$fields.first_name.value} {$fields.midle_name_c.value} {$fields.last_name.value}'

as a new key => value in array and the custom code will be displayed instead of full_name value.

Code Lღver
  • 15,573
  • 16
  • 56
  • 75
Eitrix
  • 116
  • 1
  • That's a cool quick fix. Thanks :) But I'm looking for a way through which the $bean->full_name (for Leads) is going to produce a concatenated result of all 3 fields. I traced back the routine that does this to the routine named _create_proper_name_field() in the Person class in include/SugarObjects. Am trying to figure out a way to safely override this routine as doing so will reflect the change in all possible views in Sugar. – miCRoSCoPiC_eaRthLinG Nov 26 '10 at 02:20