Field Relationships

Hi, I give a solution that should work.

Make sure to backup your system before experimenting or trying this on a copy of your live system. The idea is that you create the account_phone fields by code instead of by studio, because you cannot display custom fields in studio in other modules easily.

  • Create the file
custom/Extension/modules/Accounts/Ext/Vardefs/account_phone.php

with the following contents:


<?php
$dictionary['Account']['fields']['account_phone'] = array (
    'name' => 'account_phone',
    'vname' => 'LBL_ACCOUNT_PHONE',
    'type' => 'phone',
    'dbType' => 'varchar',
    'len' => 100,
    'audited'=>true,
    'unified_search' => true,
    'merge_filter' => 'enabled',
    'reportable' => '1',
    'importable' => 'true',
  );
  • Create the file
custom/Extension/modules/Accounts/Ext/Language/en_us.account_phone.php

with the following contents:


<?php
$mod_strings['LBL_ACCOUNT_PHONE'] = 'Account Phone';
  • Create the file
custom/Extension/modules/Prospects/Ext/Vardefs/account_phone.php

with the following contents:


<?php
$dictionary['Prospect']['fields']['accounts_prospects_1_name']['join_link_name'] = 'accounts_prospects_link';

$dictionary['Prospect']['fields']['account_phone'] = array (
		'name' => 'account_phone',
		'rname' => 'account_phone',
		'id_name' => 'accounts_prospects_1accounts_ida',
		'vname' => 'LBL_ACCOUNT_PHONE',
		'join_name'=>'accounts',
		'join_link_name'=>'accounts_prospects_link',
		'type' => 'relate',
		'link' => 'accounts_prospects_1',
		'table' => 'accounts',
		'isnull' => 'true',
		'module' => 'Accounts',
		'dbType' => 'varchar',
		'len' => '255',
		'source' => 'non-db',
		'unified_search' => true,
		'massupdate' => false,
		'studio' => array('detailview' => 'true'),
	);
  • Create the file
custom/Extension/modules/Prospects/Ext/Language/en_us.account_phone.php

with the following contents:


<?php
$mod_strings['LBL_ACCOUNT_PHONE'] = 'Account Phone';
  • Go to admin / repair
  • do a “Quick Repair and Rebuild”. It will show a Query add the bottom, make sure Execute it.
  • If you want to copy the account_phone numbers from your previously created custom field into your new custom field, then run this query in MySQL:

update accounts as a, accounts_cstm as ac set a.account_phone = ac.account_phone_c where a.id = ac.id_c;
  • Go into studio, module Accounts and delete your accounts_phone field
  • Add the new accounts_phone field to your layouts
  • Go into studio, module Targets
  • You will see the field accounts_phone in the detailview, listview layouts as well as in the basic search and advanced search. You can add this field to the layouts.
1 Like