If I try to convert a lead, the account name saved in the name field of the accounts tabel of the DB is the contact name field value.
Maybe Iāve edit something. What to check???
If I try to convert a lead, the account name saved in the name field of the accounts tabel of the DB is the contact name field value.
Maybe Iāve edit something. What to check???
Hello Valerio,
did you rename / remove any fields of the accounts / contacts module?
The standard convert feature works usually fairly well:
Did you select any pre-existing account / contact during the conversion process?
If those ideas donāt help, maybe try a new lead - convert it and show some screenshots.
I only add many custom field in leads, contacts and accounts.
Leads have 3 tabs: 1) Contact, 2) Account and 3) Other
In the following 2 images you can see Contact and Account tabs:
In the third image the lead conversion page is shown, where I have highlighted the account name both is contact and account section:
In the following last image, after conversion the account name = contact name
I assume, some field names are mixed or misplaced or similar.
In the standard installation + language pack, the company name is:
NOME AZIENDA
If I fill the company name in this field, itāll be used in the lead convert page as the company name.
The field NOME AZIENDA
doesnāt exist in my lead conversion page.
It seems to be a related field in your conversion page?
Did you add this field as an additional field in the contacts maybe?
Conversion is working as expected afterwards:
If you compare your field setup to the standard and try to remove custom fields which might interfere, it should work again.
As for the social association, it might be best to either link it only to the account only, not the lead.
Or, if you need it in the lead, then use a text field (Ragione Sociale) inside the lead and the account name and then, after converting the lead, someone needs to select the existing social association (probably an account as well) or create a new one.
In case youād like to automate this and have a mapping field, itās possible to write a logic hook to either relate an existing association or create a new one for a new company.
Hope I got the business case / requirements correctly interpreted there?
NOME AZIENDA = ACCOUNT NAME and RAGIONE SOCIALE = ACCOUNT NAME. They are only different labels.
Do you mean I have to rename NOME AZIENDA in RAGIONE SOCIALE both in the contact section of the lead module and in the contact module?
Iām not sure exactly - I canāt reproduce the issue.
I just assume, itās some custom fields / field names or similar.
Renaming the labels might not solve the issue.
Iād be curious how you got the NOME AZIENDA field into the lead conversion part for the contact.
That seems to be wrong.
If you build this one back / remove this back to the standard, it might start working again.
Iāve recovered the original /modules/Leads/metadata/convertdefs.php file and it works good.
Iāll try to repeat my customizations for the conversion page
Iāve copied the original convertdefs.php file in /custom/modules/Leads/metadata/ and modified as follow:
$viewdefs['Contacts']['ConvertLead'] = array(
'copyData' => true,
'required' => true,
'select' => "report_to_name",
'default_action' => 'create',
'templateMeta' => array(
'form'=>array(
'hidden'=>array(
'<input type="hidden" name="opportunity_id" value="{$smarty.request.opportunity_id}">',
'<input type="hidden" name="case_id" value="{$smarty.request.case_id}">',
'<input type="hidden" name="bug_id" value="{$smarty.request.bug_id}">',
'<input type="hidden" name="email_id" value="{$smarty.request.email_id}">',
'<input type="hidden" name="inbound_email_id" value="{$smarty.request.inbound_email_id}">'
)
),
'maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30'),
),
),
'panels' =>array(
'LNK_NEW_CONTACT' => array(
array(
array(
'name' => 'first_name',
'customCode' => '{html_options name="Contactssalutation" options=$fields.salutation.options selected=$fields.salutation.value} <input name="Contactsfirst_name" size="25" maxlength="25" type="text" value="{$fields.first_name.value}">',
),
'last_name',
),
array(
'phone_work',
'phone_mobile',
),
array(
'ruolo_c',
'account_name',
),
array(
'email1',
),
)
),
);
$viewdefs['Accounts']['ConvertLead'] = array(
'copyData' => true,
'required' => true,
'select' => "account_name",
'default_action' => 'create',
'relationship' => 'accounts_contacts',
'templateMeta' => array(
'form'=>array(
'hidden'=>array(
'<input type="hidden" name="opportunity_id" value="{$smarty.request.opportunity_id}">',
'<input type="hidden" name="case_id" value="{$smarty.request.case_id}">',
'<input type="hidden" name="bug_id" value="{$smarty.request.bug_id}">',
'<input type="hidden" name="email_id" value="{$smarty.request.email_id}">',
'<input type="hidden" name="inbound_email_id" value="{$smarty.request.inbound_email_id}">'
)
),
'maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30'),
),
),
'panels' =>array(
'LNK_NEW_ACCOUNT' => array(
array(
'account_vat_c',
'name',
),
array(
'account_type_c',
'account_ipa_code_c',
),
array(
'account_ipa_category_c',
'account_inhabitants_number_c',
),
array(
'phone_office',
'website',
),
array(
'account_email_c',
'account_pec_c',
),
array(
'description'
),
array(
'account_address_c',
),
array(
'account_cap_c',
'account_city_c',
),
array(
'account_acronym_district_c',
'account_district_c',
),
array(
'account_region_c',
'account_area_c',
),
)
),
);
I think the issue is here:
āLNK_NEW_ACCOUNTā => array(
array(
āaccount_vat_cā,
ānameā,
),
This ānameā in the conversion lead page is viewed as the account name, but after conversion is the contact name; if I replace ānameā with āaccount_nameā in the conversion page is showed an empty space, and after conversion the account name is the contact name
Can you describe your goal / business requirements / targeted architecture behind this?
Maybe there is a way to avoid custom code?
I need to convert leads with custom fields in contacts (only if last name is not āN/Dā, in that case Iād like the contact convertion check is unchecked) and accounts and in the convertion page the fields are disactivated.
Iāve the custom files ( /custom/modules/Leads/metadata/convertdefs.php and /custom/modules/Leads/views/view.convertlead.php). Everything is good, a part:
Code of the view.convertlead.php custom file:
<?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.getElementsByName('Contactssalutation').forEach((e) => {
e.disabled = true;
});
document.getElementsByName('Contactsfirst_name').forEach((e) => {
e.disabled = true;
});
document.getElementById('Contactslast_name').disabled=true;
document.getElementById('Contactsphone_work').disabled=true;
document.getElementById('Contactsphone_mobile').disabled=true;
document.getElementById('Contactsruolo_c').disabled=true;
document.getElementById('Contactsaccount_name').disabled=true;
document.getElementById('Accountsaccount_vat_c').disabled=true;
document.getElementById('Accountsname').disabled=true;
document.getElementById('Accountsaccount_type_c').disabled=true;
document.getElementById('Accountsaccount_ipa_code_c').disabled=true;
document.getElementById('Accountsaccount_ipa_category_c').disabled=true;
document.getElementById('Accountsaccount_inhabitants_number_c').disabled=true;
document.getElementById('Accountsphone_office').disabled=true;
document.getElementById('Accountswebsite').disabled=true;
document.getElementById('Accountsaccount_email_c').disabled=true;
document.getElementById('Accountsaccount_pec_c').disabled=true;
document.getElementById('Accountsdescription').disabled=true;
document.getElementById('Accountsaccount_address_c').disabled=true;
document.getElementById('Accountsaccount_cap_c').disabled=true;
document.getElementById('Accountsaccount_city_c').disabled=true;
document.getElementById('Accountsaccount_acronym_district_c').disabled=true;
document.getElementById('Accountsaccount_district_c').disabled=true;
document.getElementById('Accountsaccount_region_c').disabled=true;
document.getElementById('Accountsaccount_area_c').disabled=true;
</script>";
}
?>
Code of the convertdefs.php custom file:
<?php
$viewdefs['Contacts']['ConvertLead'] = array(
'copyData' => true,
'required' => true,
'select' => "report_to_name",
'default_action' => 'create',
'templateMeta' => array(
'form'=>array(
'hidden'=>array(
'<input type="hidden" name="opportunity_id" value="{$smarty.request.opportunity_id}">',
'<input type="hidden" name="case_id" value="{$smarty.request.case_id}">',
'<input type="hidden" name="bug_id" value="{$smarty.request.bug_id}">',
'<input type="hidden" name="email_id" value="{$smarty.request.email_id}">',
'<input type="hidden" name="inbound_email_id" value="{$smarty.request.inbound_email_id}">'
)
),
'maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30'),
),
),
'panels' =>array(
'LNK_NEW_CONTACT' => array(
array(
array(
'name' => 'first_name',
'customCode' => '{html_options name="Contactssalutation" options=$fields.salutation.options selected=$fields.salutation.value} <input name="Contactsfirst_name" size="25" maxlength="25" type="text" value="{$fields.first_name.value}">',
),
'last_name',
),
array(
'phone_work',
'phone_mobile',
),
array(
'ruolo_c',
'account_name',
),
array(
'email1',
),
)
),
);
$viewdefs['Accounts']['ConvertLead'] = array(
'copyData' => true,
'required' => true,
'select' => "account_name",
'default_action' => 'create',
'relationship' => 'accounts_contacts',
'templateMeta' => array(
'form'=>array(
'hidden'=>array(
'<input type="hidden" name="opportunity_id" value="{$smarty.request.opportunity_id}">',
'<input type="hidden" name="case_id" value="{$smarty.request.case_id}">',
'<input type="hidden" name="bug_id" value="{$smarty.request.bug_id}">',
'<input type="hidden" name="email_id" value="{$smarty.request.email_id}">',
'<input type="hidden" name="inbound_email_id" value="{$smarty.request.inbound_email_id}">'
)
),
'maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30'),
),
),
'panels' =>array(
'LNK_NEW_ACCOUNT' => array(
array(
'account_vat_c',
'name',
),
array(
'account_type_c',
'account_ipa_code_c',
),
array(
'account_ipa_category_c',
'account_inhabitants_number_c',
),
array(
'phone_office',
'website',
),
array(
'account_email_c',
'account_pec_c',
),
array(
'description'
),
array(
'account_address_c',
),
array(
'account_cap_c',
'account_city_c',
),
array(
'account_acronym_district_c',
'account_district_c',
),
array(
'account_region_c',
'account_area_c',
),
)
),
);
$viewdefs['Opportunities']['ConvertLead'] = array(
'copyData' => true,
'required' => false,
'templateMeta' => array(
'form'=>array(
'hidden'=>array(
)
),
'maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30'),
),
),
'panels' =>array(
'LNK_NEW_OPPORTUNITY' => array(
array(
'name',
'currency_id'
),
array(
'sales_stage',
'amount'
),
array(
'date_closed',
''
),
array(
'description'
),
)
),
);
$viewdefs['Notes']['ConvertLead'] = array(
'copyData' => false,
'required' => false,
'templateMeta' => array(
'form'=>array(
'hidden'=>array(
'<input type="hidden" name="opportunity_id" value="{$smarty.request.opportunity_id}">',
'<input type="hidden" name="case_id" value="{$smarty.request.case_id}">',
'<input type="hidden" name="bug_id" value="{$smarty.request.bug_id}">',
'<input type="hidden" name="email_id" value="{$smarty.request.email_id}">',
'<input type="hidden" name="inbound_email_id" value="{$smarty.request.inbound_email_id}">'
)
),
'maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30'),
),
),
'panels' =>array(
'LNK_NEW_NOTE' => array(
array(
array('name'=>'name', 'displayParams'=>array('size'=>90)),
),
array(
array('name' => 'description', 'displayParams' => array('rows'=>10, 'cols'=>90) ),
),
)
),
);
$viewdefs['Calls']['ConvertLead'] = array(
'copyData' => false,
'required' => false,
'templateMeta' => array(
'form'=>array(
'hidden'=>array(
'<input type="hidden" name="opportunity_id" value="{$smarty.request.opportunity_id}">',
'<input type="hidden" name="case_id" value="{$smarty.request.case_id}">',
'<input type="hidden" name="bug_id" value="{$smarty.request.bug_id}">',
'<input type="hidden" name="email_id" value="{$smarty.request.email_id}">',
'<input type="hidden" name="inbound_email_id" value="{$smarty.request.inbound_email_id}">',
'<input type="hidden" name="Callsstatus" value="{sugar_translate label=\'call_status_default\'}">',
)
),
'maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30'),
),
),
'panels' =>array(
'LNK_NEW_CALL' => array(
array(
array('name'=>'name', 'displayParams'=>array('size'=>90)),
),
array(
'date_start',
array(
'name' => 'duration_hours',
'label' => 'LBL_DURATION',
'customCode' => '{literal}
<script type="text/javascript">
function isValidCallsDuration() {
form = document.getElementById(\'ConvertLead\');
if ( form.duration_hours.value + form.duration_minutes.value <= 0 ) {
alert(\'{/literal}{sugar_translate label="NOTICE_DURATION_TIME" module="Calls"}{literal}\');
return false;
}
return true;
}
</script>{/literal}
<input name="Callsduration_hours" tabindex="1" size="2" maxlength="2" type="text" value="{$fields.duration_hours.value}"/>
{assign var="minutes_values" value=$bean->minutes_values}
{html_options name="Callsduration_minutes" options=$minutes_values selected=$fields.duration_minutes.value}
<span class="dateFormat">{sugar_translate label="LBL_HOURS_MINUTES" module="Calls"}',
'displayParams' =>
array(
'required' => true,
),
),
),
array(
array('name' => 'description', 'displayParams' => array('rows'=>10, 'cols'=>90) ),
),
)
),
);
$viewdefs['Meetings']['ConvertLead'] = array(
'copyData' => false,
'required' => false,
'relationship' => 'meetings_users',
'templateMeta' => array(
'form'=>array(
'hidden'=>array(
'<input type="hidden" name="opportunity_id" value="{$smarty.request.opportunity_id}">',
'<input type="hidden" name="case_id" value="{$smarty.request.case_id}">',
'<input type="hidden" name="bug_id" value="{$smarty.request.bug_id}">',
'<input type="hidden" name="email_id" value="{$smarty.request.email_id}">',
'<input type="hidden" name="inbound_email_id" value="{$smarty.request.inbound_email_id}">',
'<input type="hidden" name="Meetingsstatus" value="{sugar_translate label=\'meeting_status_default\'}">',
)
),
'maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30'),
),
),
'panels' =>array(
'LNK_NEW_MEETING' => array(
array(
array('name'=>'name', 'displayParams'=>array('size'=>90)),
),
array(
'date_start',
array(
'name' => 'duration_hours',
'label' => 'LBL_DURATION',
'customCode' => '{literal}
<script type="text/javascript">
function isValidMeetingsDuration() {
form = document.getElementById(\'ConvertLead\');
if ( form.duration_hours.value + form.duration_minutes.value <= 0 ) {
alert(\'{/literal}{sugar_translate label="NOTICE_DURATION_TIME" module="Calls"}{literal}\');
return false;
}
return true;
}
</script>{/literal}
<input name="Meetingsduration_hours" tabindex="1" size="2" maxlength="2" type="text" value="{$fields.duration_hours.value}" />
{assign var="minutes_values" value=$bean->minutes_values}
{html_options name="Meetingsduration_minutes" options=$minutes_values selected=$fields.duration_minutes.value}
<span class="dateFormat">{sugar_translate label="LBL_HOURS_MINUTES" module="Calls"}',
'displayParams' =>
array(
'required' => true,
),
),
),
array(
array('name' => 'description', 'displayParams' => array('rows'=>10, 'cols'=>90) ),
),
)
),
);
$viewdefs['Tasks']['ConvertLead'] = array(
'copyData' => false,
'required' => false,
'templateMeta' => array(
'form'=>array(
'hidden'=>array(
'<input type="hidden" name="opportunity_id" value="{$smarty.request.opportunity_id}">',
'<input type="hidden" name="case_id" value="{$smarty.request.case_id}">',
'<input type="hidden" name="bug_id" value="{$smarty.request.bug_id}">',
'<input type="hidden" name="email_id" value="{$smarty.request.email_id}">',
'<input type="hidden" name="inbound_email_id" value="{$smarty.request.inbound_email_id}">'
)
),
'maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30'),
),
),
'panels' =>array(
'LNK_NEW_TASK' => array(
array(
array('name'=>'name', 'displayParams'=>array('size'=>90)),
),
array(
'status', 'priority'
),
array(
array('name' => 'description', 'displayParams' => array('rows'=>10, 'cols'=>90) ),
),
)
),
);
No other suggestions to achieve my goals???
Try a workflow to rename the account based on the related lead.
@BastianHammer do you have some other suggestions?
@Vale1976
Iād probably try to stick close to the standards - like Paul suggested.
Can you elaborate on your business requirements more, ignoring technical approaches?
There are two type of leads - one with the last name N/D and others not.
And now?
And now I need to convert Leads with custom fields in Contacts (only if the last name of the contact is different from N/D) and Accounts. Contacts and Accounts have custom fields in line with the Leads. If possible, if the last name of the contact is = N/D the Convert Contact checkbox in Lead convertion page should be unchecked.
The custom scripts in the previous message do that, a part that: