AnsweredAssumed Answered

Auto populate custom fields on Opportunity using a Relate field

Question asked by mayank.chandan on Jul 12, 2014
I have two custom fields on opportunity, City and State. Whenever an Account (Through relate field) is mapped with an Opportunity (On Edit view). It should auto populate custom fields (State and City) of opportunity with Billing State & City from Accounts

These should work with Account selection through pop up and by typing (Quick Search) in the account Relate Field

Proposed Solution

Schema (Field names) -- Opportunity Module
account_id (Hidden )
account_name (Relate Field)
city_c (custom field)
state_c (custom field)

Schema (Field names) -- Accounts Module
id (id)
name (account name) 
billing_address_city (custom field)
billing_address_state (custom field)

// For quick search
Adding attributes of populate_list & field_list in custom/modules/Opportunities/Ext/Vardefs/vardef.php

$dictionary['Opportunity']['fields']['account_name']['populate_list'] = array('name', 'id', 'billing_address_city','billing_address_state');
$dictionary['Opportunity']['fields']['account_name']['field_list'] = array('account_name','account_id','city_c','state_c');


// For Pop up

Modifying the display Params of a relate field in custom/modules/opportunities/metadata/editviewdefs.php

array (          0 => 'account_name',
          'displayParams' => 
          array (
             'field_to_name_array' => array (
             'name' => 'account_name',

Solution for quick search is working but not for pop up. Not sure what have I done  wrong over

I referred the below url to get these working

Any input on the above is highly appreciated.

Mayank Chandan