AnsweredAssumed Answered

Field type "related" and rname distinct than "name" show no value on detail view

Question asked by jfernandez on Aug 17, 2015
I have a field on destination table named as "destination_city" that will contains an id from the city table. The city table have a field "citycountry_name_c" that cotain a concatenation like "City name (Country)":

mysql> desc destination;
+--------------------------+---------------+------+-----+---------+
| Field                    | Type          | Null | Key | Default |
+--------------------------+---------------+------+-----+---------+
| id                       | char(36)      | NO   | PRI | NULL    |
| name                     | varchar(255)  | YES  |     | NULL    |
| description              | text          | YES  |     | NULL    |
| destination_city         | char(80)      | YES  |     | NULL    |
+--------------------------+---------------+------+-----+---------+
mysql> desc city;
+------------------------+--------------+------+-----+---------+
| Field                  | Type         | Null | Key | Default |
+------------------------+--------------+------+-----+---------+
| id                     | char(80)     | NO   | PRI |         |
| name                   | varchar(255) | YES  |     | NULL    |
| description            | text         | YES  |     | NULL    |
| citycountry_name_c     | varchar(80)  | YES  |     | NULL    |
+------------------------+--------------+------+-----+---------+

In the /sugarcrm/custom/Extension/modules/destination/Ext/Vardefs/sugarfield_destination_city.php:

$dictionary['destination']['fields']['destination_city'] = array (
    'required' => true,
    'name' => 'destination_city',
    'vname' => 'LBL_DESTINATION_CITY',
    'type' => 'id',
    'massupdate' => false,
    'no_default' => false,
    'comments' => 'Objeto Lugar',
    'help' => '',
    'importable' => 'true',
    'duplicate_merge' => 'enabled',
    'duplicate_merge_dom_value' => '1',
    'audited' => false,
    'reportable' => false,
    'unified_search' => false,
    'merge_filter' => 'disabled',
    'full_text_search' => '' . "\0" . 'isabled',
    'calculated' => false,
    'len' => '80',
    'size' => '20',
  );
$dictionary['destination']['fields']['destination_city_name'] = array(
    'required' => true,
    'source' => 'non-db',
    'name' => 'destination_city_name',
    'id_name' => 'destination_city',
    'vname' => 'LBL_DESTINATION_CITY',
    'type' => 'relate',
    'massupdate' => false,
    'no_default' => false,
    'comments' => '',
    'help' => '',
    'importable' => 'false',
    'duplicate_merge' => 'disabled',
    'duplicate_merge_dom_value' => '0',
    'audited' => false,
    'reportable' => true,
    'unified_search' => false,
    'merge_filter' => 'disabled',
    'full_text_search' =>
    array(
        'boost' => '0',
        'enabled' => false,
    ),
    'calculated' => false,
    'len' => '255',
    'size' => '20',
    'ext2' => 'city',
    'module' => 'city',
    'rname' => 'name',
    'quicksearch' => 'enabled',
    'studio' => 'visible',
    'custom_module' => 'destination',
);
In this way, when I start to write in the search box I can see the city name, but I need to see "City name (Country)". Reading the documentation (http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_7.5/30_Data_Fr...) it should be as simple as changing the rname like this:

    'rname' => 'citycountry_name_c',

And it works on edit view, it shows me the "city name (country)" when I start to write and save the id in destination_city.

But when I go to detail view, the field is in blank and don't show any value. I'm using Sugar 7.5.2.2 Enterprise.

Outcomes