Copy account shipping address to contacts

I’ve been digging for a couple of hours now and have come up blank, I see that there is this section of code

<button type="button" name="btn_account_name" id="btn_account_name" tabindex="0" title="Select Account" class="button firstChild" value="Select Account" onclick="open_popup(
";Accounts";, 
600, 
400, 
";";, 
true, 
false, 
{";call_back_function";:";set_return";,";form_name";:";EditView";,";field_to_name_array";:{";id";:";account_id";,";name";:";account_name";,";billing_address_street";:";primary_address_street";,";billing_address_city";:";primary_address_city";,";billing_address_state";:";primary_address_state";,";billing_address_postalcode";:";primary_address_postalcode";,";billing_address_country";:";primary_address_country";,";phone_office";:";phone_work";}}, 
";single";, 
true
);"><img src="themes/SuiteR/images/id-ff-select.png?v=jp9Lgq2ZeZkJfNU5gHtUcA"></button>

On the select account button on the contact edit view, but I can’t find where this is being generated at. I would like to edit it to copy shipping address instead of billing.

I think this may be defined in modules/Contacts/metadata/editvewdefs for the account_name field. Try switching key to shipping and billingKey to shippingKey

Still the same, I changed the array to

 array (
            'name' => 'account_name',
            'displayParams' => 
            array (
              'key' => 'shipping',
              'copy' => 'primary',
              'shippingKey' => 'primary',
              'additionalFields' => 
              array (
                'phone_office' => 'phone_work',
              ),
            ),
	),

But I still get the same, and yes I rebuilt and repaired. There is an EditView.tpl that is generated in the cache but I’m not sure whats called to generate it.
Here’s the relevant section from it.

<input type="text" name="{$fields.account_name.name}" class="sqsEnabled" tabindex="0" id="{$fields.account_name.name}" size="" value="{$fields.account_name.value}" title='' autocomplete="off"  	 accesskey='7'  >
<input type="hidden" name="{$fields.account_name.id_name}" 
id="{$fields.account_name.id_name}" 
value="{$fields.account_id.value}">
<span class="id-ff multiple">
<button type="button" name="btn_{$fields.account_name.name}" id="btn_{$fields.account_name.name}" tabindex="0" title="{sugar_translate label="LBL_ACCESSKEY_SELECT_ACCOUNTS_TITLE"}" class="button firstChild" value="{sugar_translate label="LBL_ACCESSKEY_SELECT_ACCOUNTS_LABEL"}"
onclick='open_popup(
"{$fields.account_name.module}", 
600, 
400, 
"", 
true, 
false, 
{literal}{"call_back_function":"set_return","form_name":"EditView","field_to_name_array":{"id":"account_id","name":"account_name","billing_address_street":"primary_address_street","billing_address_city":"primary_address_city","billing_address_state":"primary_address_state","billing_address_postalcode":"primary_address_postalcode","billing_address_country":"primary_address_country","phone_office":"phone_work"}}{/literal}, 
"single", 
true
);' ><img src="{sugar_getimagepath file="id-ff-select.png"}"></button>

Sorry for not being more verbose David. Do you have a file custom/modules/Contacts/metadata/editviewdefs.php? That would be the one you would need to make the changes to and doing so would make your changes upgrade safe.

Excellent, that did it for me. Thank you very much. I’m still curious how the editview.tpl is generated though, if you’ve got any info on that it’d be much appreciated.

Even more thanks if you can point me in the appropriate direction to populate the address field when using the create option on an account.
Editing the view.quickcreate.php to

require_once('include/MVC/View/views/view.quickcreate.php');

class ContactsViewQuickcreate extends ViewQuickcreate
{
    public function preDisplay() 
    {
    	parent::preDisplay();
    	if($this->_isDCForm) {
    		//XXX TODO 20110329 Frank Steegmans: Hack to make quick create fields populate when used through the DC menu
    		//          NOTE HOWEVER that sqs_objects form fields are not properly populated because of some other hacks
    		//          resulting in none of the fields properly populating when selecting an account
    		if(!empty($this->bean->phone_office))$_REQUEST['phone_work'] = $this->bean->phone_office;
    		if(!empty($this->bean->shipping_address_street))$_REQUEST['primary_address_street'] = $this->bean->shipping_address_street;
    		if(!empty($this->bean->shipping_address_city))$_REQUEST['primary_address_city'] = $this->bean->shipping_address_city;
    		if(!empty($this->bean->shipping_address_state))$_REQUEST['primary_address_state'] = $this->bean->shipping_address_state;
    		if(!empty($this->bean->shipping_address_country))$_REQUEST['primary_address_country'] = $this->bean->shipping_address_country;
    		if(!empty($this->bean->shipping_address_postalcode))$_REQUEST['primary_address_postalcode'] = $this->bean->shipping_address_postalcode;
	   	}
    }    
}

Did not do what I expected.

I’d suggest checking if there is a custom/modules/Contacts/views/view.quickcreate.php. There likely isn’t one but if there is make your changes there. If there isn’t create it and include and extend the ContactsViewQuickCreate with a CustomContactsViewQuickCreate class and make your edits there. Looks like the code you have should work.

Another option is to look at updating the controller.php for Contacts

Good luck and hope this helps

Hi David,

I’m trying to implement this within our instance, but not having any joy with quick create. I was wondering if you had managed to implement this and if so where did you have to make the changes to do so?

thanks
Matt