How to copy lead custom field value as opportunity name while converting

Hi,
I want to copy a custom field value from lead as opportunity name while converting lead to opportunity. Can anybody advise how and where to do this ?

Thanks in advance.

Regards,

Umesh

@umesh.m
Look at the files:

  1. modules/Leads/views/view.convertlead.php
  2. modules/Leads/metadata/convertdefs.php

I think that the answers here.

Hi,
I’ve tried this in the below code in convertdefs.php. project_name_c is the custom field in Leads.

$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' => 'project_name_c',
                'currency_id'
            ), 
            array (
                'sales_stage',
                'amount'
            ),
            array (
                'date_closed',
                ''
            ),
            array (
                'description'
            ),
        )
    ),
);

It copies the value correctly in the opportunity name in the user interface, however, while saving the opportunity is save with the contact name. I don’t understand why this happens.

Please advise.

Thanks.

@umesh.m
Function of saving data is ‘handleSave’ in file ‘modules/Leads/views/view.convertlead.php’
You can do your decision in ‘custom’ structure of directories.

Hi,
If it write the code in ‘handleSave’ function, will it show the copied value in edit view also or it will just copy in the background while saving the form? I want to show the copied value in the edit view also, that’s the reason i’m not handling this in logic hooks.

Please advise.

Thanks.

@umesh.m
The function works after you push button ‘Convert Lead’. The fileds are presenting on the form that time alrady.
I think that in this situation logichook don’t be useful.

Hi,
I’m not able to find the solution. In my code which i posted earlier, I believe the ‘copyData’ => true is creating the issue as while saving it’s copying the name from lead to opportunity. I’m not able to find out the solution.

Can anyone help ?

Thanks.

@umesh.m
Did you make in module ‘Opportunities’ the field with name ‘project_name_c’ ?
I tested, all work. Your file ‘convertdefs.php’ is correct.

Yes, ‘project_name_c’ is in both Leads and Opportunities module. It copies the values correctly while converting the Lead to Opportunity, but while saving the Opportunity it’s copying the contact name in the name field of the opportunity, i don’t know why.

Hi,
Can this be achieved using cusom code? I’ve selected project in Lead and while converting to opportunity i want to copy project name to opportunity name in the editview form. below is the code for viewdefs

$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'
            ),
			array (
				'project_c',
			),
        )
    ),
);

I need to have the custom code for name field.

Thanks.

Umesh