How to autofill custom fields in lead on creating a new lead for an existing contact?


How to autofill custom fields in lead on creating a new lead for an existing contact? I mean in the attached screenshot you can see that the contact name and account name is automatically filled by the system on creating a new lead for an existing contact but all the custom fields are empty. Is there anyway we can pull all the filled details from an existing contact fields to a new lead fields?

one way is to rewrite some module files to call ajax action that load leads information and on return javascript load the value on the fields you want.

Or using the workflow module you can write a rule that assign the values to the field but only after save, not when you choose the leads

1 Like

I tried the workflow module but couldn’t figure the exact settings. Can you please help me with this? Or even with the codes if you can?

Probably with workflow is not possible because you can assign a value at the fields of Leads but you can not get every linked modules fields (only account name and description or contact name). If you want to get other information you need to write some code to override Leads QuickCreations and EditView.

There are to override some files to obtain the desired result, i have to see how Leads module work but i think you need to rewrite editviewdef.php to add js (if needed) and view.edit.php or controller.php to work with the data to display.

I never tried it, but perhaps this logic_hook would do what you need?

Fired when a record is processed ready to be displayed in list views or dashlets.

Maybe you can try it, or look for another logic_hook that fires at that moment.

1 Like

No it doesn’t. He process a record before show it in a list or dashlet.

He need to work on record on quick create (or edit) and there aren’t logic hook fired “on create”. There are hooks for “relationship creation” but are fired after save and they don’t work on data before display.


I tried some logic hooks before but it doesn’t work. I’m still trying different ways to achieve this goal meanwhile if you guys can help, I’ll really appreciate.

Hi bwtadnan,

to automatic insert contacts and accounts field vaule in QuickCreate fields of Leads you can override the view of Leads module

Create the file view.edit.php inside the folder “custom/modules/Leads/views” and extends the class EditView.

Inside the method “display” you can intercept the values of the request and load everything you want from database.
To add a default value to the form of QuickCreate, just add the value to the $_REQUEST

For example, set TITLE of the Leads with the TITLE of the contact.

require_once 'modules/Leads/views/view.edit.php';

class CustomLeadsViewEdit extends LeadsViewEdit{

 	public function __construct()
 		$this->useForSubpanel = true;
 		$this->useModuleQuickCreateTemplate = true;
      	function display(){
            if(isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != null && $_REQUEST['contact_id'] != ''){
                $contact = new Contact();
                $_REQUEST['title'] = $contact->title;
            if(isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != null && $_REQUEST['account_id'] != ''){
                $account = new Account();
                $_REQUEST['LEAD_CUSTOM_FIELD'] = $account->custom_field_name;



I hope this help.

1 Like