It might be better to post this message in one of the other topics related to concatenated fields. But my main goal is probably related to mentioned here “logic_hook” technique which I also use in other custom modules. And I would like to decide what to choose in the situation.
So, I need extended Accounts 'name' field into 'full_account_name' that consists of fields 'billing_address_city', custom dropdown 'account_type_drnt_c' and existing 'name' (the last is now in active use by users). The main goal is to have “one-field” identifier for Account that could clearly define it in relating modules' DetailView, pop-us and so on.
Thus I created custom/Extension/modules/Accounts/Ext/Vardefs/full_account_name.php:
PHP Code:
<?php
$dictionary['Account']['fields']['full_account_name'] = array(
'name' => 'full_account_name',
'rname' => 'full_account_name',
'vname' => 'LBL_FULL_ACCOUNT_NAME',
'type' => 'name',
'fields' => array(0 => 'billing_address_city', 1 => 'account_type_drnt_c', 2 => 'name',),
'sort_on' => 'billing_address_city',
'source' => 'non-db',
'group' => 'billing_address_city',
'len' => '255',
'dbType' => 'varchar',
'db_concat_fields' => array(0 => 'billing_address_city', 1 => 'account_type_drnt_c', 2 => 'name',),
'importable' => 'false',
);
?>
Then, of course, custom/Extension/modules/Accounts/Ext/Language/en_us.FullAccountName.php :
PHP Code:
<?php
$mod_strings['LBL_FULL_ACCOUNT_NAME'] = 'Full Account Name';
?>
Admin->Repair->Rebuild Extensions.
In Studio I placed new field in DetailView and then expected its value displayed. But the field was empty in every record. I check custom/modules/Accounts/Ext/Vardefs/vardefs.ext.php – there was the field definition there.
File custom/modules/Accounts/metadata/detailviewdefs.php also has field definition in proper place:
PHP Code:
array (
'name' => 'full_account_name',
'label' => 'LBL_FULL_ACCOUNT_NAME',
),
But 'full_account_name' field is still empty. Moreover when I placed the field in ListView it shows zero records. Removing new field from ListView gives normal view for all the records.
I dug Contacts module for similar code trying to find out what I missed. But found no differences between my code and standard Contacts 'full_name' approach. So I really appreciate if someone point me on my mistake.
The second question is about which of the techniques (logic hook or vardefs-concatenated fields) is more “Sugar-friendly” in the context of future possible bean manipulations. Which method is better to use in terms of future use cases in different situations?
Thank you!
P.S. I'm on Sugar CE 5.5.1
Bookmarks