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
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
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
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;
}
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
Try this method.
Admin->Dropdown Editor
Edit salutation_dom
Letrium ltd. - Only high quality service
http://letrium.com
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?
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:
That will change the name field in Contacts to include the suffix (change suffix_c to the correct field name).PHP Code:$GLOBALS["dictionary"]["Contact"][ 'fields']['name'] =
array (
'name' => 'name',
'rname' => 'name',
'vname' => 'LBL_NAME',
'type' => 'name',
'fields' =>
array (
0 => 'first_name',
1 => 'last_name',
2 => 'suffix_c',
),
'sort_on' => 'last_name',
'source' => 'non-db',
'group' => 'last_name',
'len' => '255',
'db_concat_fields' =>
array (
0 => 'first_name',
1 => 'last_name',
2 => 'suffix_c'
),
'importable' => 'false',
);
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
Okay, I created the above file (/custom/Extension/modules/Contacts/Ext/Vardefs/change_name.php) and now I get no contacts in my lists.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 (
0 => 'first_name',
1 => 'last_name',
2 => 'suffix_c',
),
'sort_on' => 'last_name',
'source' => 'non-db',
'group' => 'last_name',
'len' => '255',
'db_concat_fields' =>
array (
0 => 'first_name',
1 => 'last_name',
2 => 'suffix_c'
),
'importable' => 'false',
);
?>
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.
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks