Results 1 to 10 of 10

Thread: How to modify contact name to display suffix in list?

  1. #1
    rgtft is offline Senior Member
    Join Date
    Nov 2008
    Location
    East Lansing, MI
    Posts
    41

    Default How to modify contact name to display suffix in list?

    What do I need to do/modify to have the contact name suffix (e.g. Jr, Sr, III, ...) show up in a contact list?

    So the contact name looks like: Fred Smith Jr. or Fred Smith Sr.

    Thanks in advance,
    Rob

  2. #2
    crmbalah is offline A Prolific Poster
    Join Date
    Mar 2009
    Location
    chennai
    Posts
    418

    Default Re: How to modify contact name to display suffix in list?

    HI
    try to write custom code in detailviewdef.php and listviewdefs.php

  3. #3
    rgtft is offline Senior Member
    Join Date
    Nov 2008
    Location
    East Lansing, MI
    Posts
    41

    Default Re: How to modify contact name to display suffix in list?

    Quote Originally Posted by crmbalah View Post
    HI
    try to write custom code in detailviewdef.php and listviewdefs.php
    Do you have any further suggestions; my /modules/Contacts/metatdata/listviewdefs.php looks like (below):

    It appears that the $FULL_NAME variable contains the contact name. Where does that $FULL_NAME variable get set? I would assume that is where I could alter the assignment to add in a suffix or middle name to the $FULL_NAME variable

    PHP Code:
    $listViewDefs['Contacts'] = array(
            
    'NAME' => array(
                    
    'width' => '20%',
                    
    'label' => 'LBL_LIST_NAME',
                    
    'link' => true,
            
    'contextMenu' => array('objectType' => 'sugarPerson',
                                   
    'metaData' => array('contact_id' => '{$ID}',
                                                       
    'module' => 'Contacts',
                                                       
    'return_action' => 'ListView',
                                                       
    'contact_name' => '{$FULL_NAME}',
                                                       
    'parent_id' => '{$ACCOUNT_ID}',
                                                       
    'parent_name' => '{$ACCOUNT_NAME}',
                                                       
    'return_module' => 'Contacts',
                                                       
    'return_action' => 'ListView',
                                                       
    'parent_type' => 'Account',
                                                       
    'notes_parent_type' => 'Account')
                                  ),
                    
    'orderBy' => 'name',
            
    'default' => true,
            
    'related_fields' => array('first_name''last_name''salutation''account_name''account_id'),
                    ),
            
    'TITLE' => array( 
    ...

    Using Sugar CE 5.1

  4. #4
    rgtft is offline Senior Member
    Join Date
    Nov 2008
    Location
    East Lansing, MI
    Posts
    41

    Default Re: How to modify contact name to display suffix in list?

    I see a function return_name in the file /include/utils.php. It would appear that this is where the $FULL_NAME variable is getting assigned. I'm not sure what (or if) my middle name column is or my suffix column is in the $row variable. I have two fields in Studio for Contacts for middle name and suffix. I'm guessing this is where I can modify the PHP to add suffix and/or middle name to the $FULL_NAME string variable.

    Is this an upgrade safe? (I'm guessing no)

    PHP Code:
    function return_name($row$first_column$last_column)
    {
            
    $first_name "";
            
    $last_name "";
            
    $full_name "";

            if(isset(
    $row[$first_column]))
            {
                    
    $first_name stripslashes($row[$first_column]);
            }

            if(isset(
    $row[$last_column]))
            {
                    
    $last_name stripslashes($row[$last_column]);
            }

            
    $full_name $first_name;

            
    // If we have a first name and we have a last name
            
    if($full_name != "" && $last_name != "")
            {
                    
    // append a space, then the last name
                    
    $full_name .= " ".$last_name;
            }
            
    // If we have no first name, but we have a last name
            
    else if($last_name != "")
            {
                    
    // append the last name without the space.
                    
    $full_name .= $last_name;
            }

            return 
    $full_name;


  5. #5
    AlexAv's Avatar
    AlexAv is offline Sugar Community Member
    Join Date
    Oct 2009
    Location
    Ukraine
    Posts
    922

    Default Re: How to modify contact name to display suffix in list?

    No it is not upgrade save method.
    Last edited by AlexAv; 2009-11-19 at 01:30 PM.
    Letrium ltd. - Only high quality service
    http://letrium.com

  6. #6
    AlexAv's Avatar
    AlexAv is offline Sugar Community Member
    Join Date
    Oct 2009
    Location
    Ukraine
    Posts
    922

    Default Re: How to modify contact name to display suffix in list?

    Try this method.

    Admin->Dropdown Editor

    Edit salutation_dom
    Letrium ltd. - Only high quality service
    http://letrium.com

  7. #7
    rgtft is offline Senior Member
    Join Date
    Nov 2008
    Location
    East Lansing, MI
    Posts
    41

    Default Re: How to modify contact name to display suffix in list?

    Quote Originally Posted by AlexAv View Post
    Try this method.

    Admin->Dropdown Editor

    Edit salutation_dom
    This allows me to add/edit salutations (e.g. Mr, Mrs, Dr, ...) which do show up in the name, but what I want is to include the middle name and suffix fields (which I've added to my contacts via Studio) so a name will show up as:

    Joe Q Public Jr or
    Fred J Smity III

    Or am I missing something from your suggestion?

  8. #8
    mvngti is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    South Africa
    Posts
    510

    Default Re: How to modify contact name to display suffix in list?

    If you added the suffix field in studio then the internal field name will be suffix_c if you called it suffix.

    So $row['suffix_c'] will contain it in the code below, but it is definitely not upgrade safe.

    To do it upgrade safe create a file custom/Extension/modules/Contacts/Ext/Vardefs/change_name.php with this:
    PHP Code:
    $GLOBALS["dictionary"]["Contact"][ 'fields']['name'] =
        array (
          
    'name' => 'name',
          
    'rname' => 'name',
          
    'vname' => 'LBL_NAME',
          
    'type' => 'name',
          
    'fields' =>
          array (
            
    => 'first_name',
            
    => 'last_name',
            
    => 'suffix_c',
          ),
         
    'sort_on' => 'last_name',
          
    'source' => 'non-db',
          
    'group' => 'last_name',
          
    'len' => '255',
          
    'db_concat_fields' =>
          array (
            
    => 'first_name',
            
    => 'last_name',
            
    => 'suffix_c'
          
    ),
          
    'importable' => 'false',
        ); 
    That will change the name field in Contacts to include the suffix (change suffix_c to the correct field name).
    Remember to do a quick repair on the Contacts module to rebuild the vardefs.

    M
    --


    Marnus van Niekerk

    There are only 10 types of people in the world
    those who can read binary and those who don't

    Modules:
    CE Teams - Upgrade safe teams module for Community Edition
    FieldACL - Field Level Access Control for Community Edition
    EditLogicHooks - Create and edit Logic Hooks from the Admin GUI
    FlexibleChartDashlet - Display any data in a Dashlet Chart
    DocumentThumbnails - Thumbnails for Documents module

    Many questions can be answered by reading the Developers Manual

  9. #9
    rgtft is offline Senior Member
    Join Date
    Nov 2008
    Location
    East Lansing, MI
    Posts
    41

    Default Re: How to modify contact name to display suffix in list?

    Quote Originally Posted by mvngti View Post
    If you added the suffix field in studio then the internal field name will be suffix_c if you called it suffix.

    That will change the name field in Contacts to include the suffix (change suffix_c to the correct field name).
    Remember to do a quick repair on the Contacts module to rebuild the vardefs.
    PHP Code:
    <?php
    /*
      Change layout of name to include suffix
    */
    $GLOBALS["dictionary"]["Contact"][ 'fields']['name'] =
        array (
          
    'name' => 'name',
          
    'rname' => 'name',
          
    'vname' => 'LBL_NAME',
          
    'type' => 'name',
          
    'fields' =>
          array (
            
    => 'first_name',
            
    => 'last_name',
            
    => 'suffix_c',
          ),
         
    'sort_on' => 'last_name',
          
    'source' => 'non-db',
          
    'group' => 'last_name',
          
    'len' => '255',
          
    'db_concat_fields' =>
          array (
            
    => 'first_name',
            
    => 'last_name',
            
    => 'suffix_c'
          
    ),
          
    'importable' => 'false',
        );
    ?>
    Okay, I created the above file (/custom/Extension/modules/Contacts/Ext/Vardefs/change_name.php) and now I get no contacts in my lists.

    I also get an error (see below) at the bottom of my Accounts page which looks like the SQL SELECT is looking for the suffix_c field in the accounts table rather than accounts_cstm where the field really is.


    Error retrieving Account list: Query Failed:
    SELECT contacts.id,
    contacts_cstm.deanumber_c,
    <snip long list of fields>
    </snip>
    contacts.first_name , contacts.last_name , CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''),' ',IFNULL(contacts.suffix_c,'')) as name, contacts.primary_address_city , contacts.primary_address_state , contacts.phone_work , contacts.assigned_user_id , 'contacts' panel_name
    FROM contacts
    LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c
    INNER JOIN accounts_contacts ON (contacts.id=accounts_contacts.contact_id AND accounts_contacts.account_id= '547')
    where ( accounts_contacts.deleted=0 AND contacts.deleted=0) AND contacts.deleted=0 ORDER BY contacts.last_name,contacts.first_name asc LIMIT 0,10::MySQL error 1054: Unknown column 'contacts.suffix_c' in 'field list'

    Thankfully, I'm now doing this in a dev environment, so no harm is being done by experimenting.

  10. #10
    mvngti is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    South Africa
    Posts
    510

    Default Re: How to modify contact name to display suffix in list?

    If SugarCRM qualifies the field as contacts.suffix_c in the SQL query then there is no upgrade sage way to do this.

    Sorry - you will have to edit the code to include the field as you suggested originally.

    M
    --


    Marnus van Niekerk

    There are only 10 types of people in the world
    those who can read binary and those who don't

    Modules:
    CE Teams - Upgrade safe teams module for Community Edition
    FieldACL - Field Level Access Control for Community Edition
    EditLogicHooks - Create and edit Logic Hooks from the Admin GUI
    FlexibleChartDashlet - Display any data in a Dashlet Chart
    DocumentThumbnails - Thumbnails for Documents module

    Many questions can be answered by reading the Developers Manual

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to modify contact name to display suffix in list?
    By rgtft in forum Developer Tutorials
    Replies: 0
    Last Post: 2009-08-06, 07:13 PM
  2. Replies: 0
    Last Post: 2008-08-06, 09:14 AM
  3. Modify Label in detail display of History
    By mmansperger in forum Developer Help
    Replies: 2
    Last Post: 2008-03-26, 05:08 AM
  4. Replies: 2
    Last Post: 2005-09-27, 09:40 PM
  5. Replies: 0
    Last Post: 2005-09-08, 08:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •