Converting Leads with custom fields, then how to copy the Leads custom fields into the new Accounts?

Use this where you have created a custom field within Leads module and you want to be able to map that field to a standard field in Accounts, or where you have custom fields in each module with mismatched names.

1 - Create a Copy of /modules/Leads/views/view.convertlead.php in custom/modules/Leads/views/ // Keep things upgrade safe :wink:
2 - Edit you copy in /custom directy

Within protected function handleSave() // Starts at line 352

Below this snippet :


451 $this->populateNewBean($module, $beans[$module], $beans['Contacts'], $lead);
452 // when creating a new contact, create the id for linking with other modules
453 // and do not populate it with lead's old account_id
454 if ($module == 'Contacts')
455 {
456        $beans[$module]->id = create_guid();
457        $beans[$module]->new_with_id = true;
458        $beans[$module]->account_id = '';
459  }

 // Insert your code from here ( i.e line 460 ) put something like this
 // Below you can use mapping against standard modules, to custom lead fields as follows
 if ($module == 'Accounts')
  {
      // Here I Map custom wfs_industry_c ( a dropdown field, which uses industry_dom, as does Accounts )
      // These mappings operate in the background, so you will not see these fields in the Convert UI
      // Also NOTE: This modification is not necessary if your Account field and Lead field have the identical name,
      // as that is taken care of automatically.
      // See also
      $beans[$module]->industry = $lead->wfs_industry_c;
   }

Hope you find this useful

1 Like