I’ve set “N/D” as default value for last_name field in lead module for the leads without a contact but with only an account.
In lead convert I would like to set empty value for last_name field if the original value is “N/D”.
I tried this solution, but the options for the “Run” field are Always, Only On Save and Only In The Scheduler. I need to make “last_name” field empty only when such field value is N/D in lead convert page.
If you want to make the last_name empty on convert lead page if it is ‘N/D’ on leads detail view, you can change that on convert lead page in this file custom\modules\Leads\views\view.convertlead.php (create the file and extend the class and override the getRecord method.
require_once('modules\Leads\views\view.convertlead.php');
class CustomLeadsViewConvertLead extends ViewConvertLead
{
protected function getRecord()
{
$this->focus = BeanFactory::newBean('Leads');
if (isset($_REQUEST['record'])) {
$this->focus->retrieve($_REQUEST['record']);
if($this->focus->last_name == 'N/D'){
$this->focus->last_name='';
}
}
}
}
I tried your suggestion but, when I click on Convert Lead, I have the code of the custom\modules\Leads\views\view.convertlead.php file and nothing else, as you can see in the following image
For unchecking ‘Create Contact’, may be you can create copy of convertdefs file for no contact with copyData, required equal to false and no default_action and override ‘loadDefs’ method in CustomLeadsViewConvertLead class to set the new metadatafile path if last_name is ‘N/D’. I am not sure if this is a good solution because we have two different versions of the defs file.
Just create a custom conversion file. Map the field and just add you logic to populate $lastname.
Below is an example to populate an account field but you can do the same to populate a contact in the appropriate section:
How to Populate Custom Fields on Convert
Create a Copy of /modules/Leads/views/view.convertlead.php in
custom/modules/Leads/views/ …
Edit you copy in /custom directly
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:
// 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;
}
so your logic would be something like: $lastname = $lead -> lastaname … if $lead->lastname = "N/D" then $lastname = "null"
I’ve mapped the field for convertion in the file /modules/Leads/views/view.convertlead.php; then I’ve copied it in custom/modules/Leads/views/ and then I’ve added the following code from line 463 but nothing changed
if ($beans['Contacts']->last_name == "N/D") {
$beans['Contacts']->last_name = NULL;
}
The exsmple was for accounts. Its not exactly at line 463 you have you add it in the part that deals with the contact creation. Also you have you repair and rebuild before changes will take effect. Also i think you want lead last name not contact last name equals n/d then updates the contact.