This is the format you have to use for the Contacts, and it has to be in the contact section. This will work, if you modifiy it properly for your purposes and put it in the part that deals with the contact creation. I’ve given you an example, I’m not going to code it for you, but here’s where the changes need to go I think, this file has changed considerably since the last time I did it:
I have repair and rebuild in both cases
I tried both
if ($beans[$module]->last_name == "N/D") {
$beans[$module]->last_name = '';
}
and
if ($lead->last_name == "N/D") {
$beans[$module]->last_name = '';
}
at the end of the following code ( before the “}” )
if ($module == 'Contacts') {
$beans[$module]->id = create_guid();
$beans[$module]->new_with_id = true;
$beans[$module]->account_id = '';
}
but nothing changes: the last_name field still contains N/D
Try == null rather than “” see if that helps.
I tried aldo to add only $beans[$module]->last_name = 'hello'; and it doesn’t work anyway.
The code is changed in /custom/modules/Leads/views/view.convertlead.php.
I also had repair and rebuild.
What’s wrong???
Neither = NULL rather than = “” helps
![]()
Just tried it, it works perfectly.
If it’s not working for you something else must be going on.
Are you sure the file has the correct permissions?
If you are using SuiteCRM 8 it has to be …legacy/custom/module/Leads/view.covertlead.php
Other than that, I’m out of ideas as to why it’s not working for you.
This works for me, but not sure why it doesn’t work for him.
Overriding the protected method getRecord where last name is set to empty if n/d.
@Harshad solution works!!! Great ![]()
Only I replaced \ with / in the path of the require_once.
Now… in order to achieve my objective, I would like that:
- when last_name == ‘N/D’, then only the account_name of the contact convertion form is automatically = ‘’ (as the last_name field) and the account_name of the account convertion form preserves the original value and the New Contact Or Select Contact checkbox is autoamtically unchecked
- when last_name !== ‘N/D’, then the account_name of the contact convertion form is always = the account_name of the account convertion form
In both cases the account_name of the contact convertion form should be inactive so users can’t change its value
After coding the /public/legacy/custom/modules/Leads/view/view.convertlead.php as follow:
if ($module == 'Contacts') {
$beans[$module]->id = create_guid();
$beans[$module]->new_with_id = true;
$beans[$module]->account_id = '';
$beans[$module]->last_name = 'hello';
}
I run the command sudo chown www-data:www-data /var/www/suitecrm -R and the repair and rebuild but nothing changed.
I also tried to change the /public/legacy/modules/Leads/view/view.convertlead.php file, repair and rebuild and then set the right permissions; nothing changed again.
@pstevens your second image is not the convertion page
@Vale1976 the second image is not the conversion page. There are no changes on the conversion page. The logic kicks in on save of the record. The image is of the successful change to the coded logic when the contact is created.
Are you sure your using the default last_name field and not a custom last name field? I can’t think of anything else that would cause this not to work.
I would next add an output to log at the top of the file. This will tell you definitely if the file is getting executed.
Yes, I’m sure. In fact the following code suggested by @Harshad works very well.
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='';
}
}
}
}
Can you please replace existing code with this.
<?php
require_once('modules/Leads/views/view.convertlead.php');
class CustomLeadsViewConvertLead extends ViewConvertLead
{
public function display()
{
parent::display();
echo "<script type='text/javascript'>
let last_name = document.getElementById('Contactslast_name').value;
if(last_name==='N/D'){
document.getElementById('Contactslast_name').value='';
toggleDisplay('createContacts');if (typeof(addRemoveDropdownElement) == 'function') addRemoveDropdownElement('Contacts');toggleContactsSelect();
document.getElementById('newContacts').checked=false;
}
document.getElementById('Accountsname').disabled=true;
</script>
";
}
}
What I see is shown in the attached image. The contact conversion checkbox is checked is spite of document.getElementById('newContacts').checked=false;
In my method above by editing the converdefs.php you can change required to false in the viewsdefs.
Your method didn’t work for me
In your code file view.convertlead.php in custom folder, getRecord() method should be removed if it is preset, we need only display() method.
Another Method
You can try this method method to load defs file if the last_name is ‘N/D’. Please try
- copy the modules/Leads/metadata/convertdefs.php at custom/modules/Leads/metadata/convertnocontactdefs.php
- set the following properties with values as shown
$viewdefs['Contacts']['ConvertLead'] = array(
'copyData' => false,
'required' => false,
'select' => "report_to_name",
- Override the loadDefs() method in custom/modules/Leads/views/view.convertlead.php as
<?php
require_once('modules/Leads/views/view.convertlead.php');
class CustomLeadsViewConvertLead extends ViewConvertLead
{
public function display()
{
parent::display();
echo "<script type='text/javascript'>
let last_name = document.getElementById('Contactslast_name').value;
if(last_name==='N/D'){
document.getElementById('Contactslast_name').value='';
toggleDisplay('createContacts');if (typeof(addRemoveDropdownElement) == 'function') addRemoveDropdownElement('Contacts');toggleContactsSelect();
}
document.getElementById('Accountsname').disabled=true;
</script>
";
}
protected function loadDefs()
{
$viewdefs = array();
if($this->bean->last_name=='N/D'){
$this->medataDataFile = 'custom/modules/Leads/metadata/convertnocontactdefs.php';
}
include($this->medataDataFile);
$this->defs = $viewdefs;
}
}
I tried your suggestion but the contact conversion checkbox is checked and the standard conversion page is loaded, not the lead conversion customizations.
The protected function loadDefs() does not work as expected.



