function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Yamini BathulaYamini Bathula 

Lead Conversion in Lightning

Hi Guys,

We have moved to Lightning recently. The issue is now with Lead Conversion. In lightning if users dont enter Opportunity name in conversion window then the Opporutnity is not created. So we wanted to automate opp creation if the user has missed populating the Opporutniy Name field. 
I wrote trigger for that and it is working fine. But the only issue is the newly created opporutnity  doesnt have any lead fields mapped from Lead as the standard Lead conversion do.

Soes nay one have any idea of how to achieve the Lead Field mapping in the trigger instead of writing assignment statements in the trigger?

Here is my trigger:
trigger LeadConversionOppCreation on Lead (after update) 
 if ( == 1) 

    if (Trigger.old[0].isConverted == false &&[0].isConverted == true)
         if ([0].ConvertedAccountId != null) 
              Account a = [Select a.Id, a.Description From Account a Where a.Id =[0].ConvertedAccountId];
              if ([0].ConvertedOpportunityId == null) 
                 Opportunity opp = new Opportunity();
                 opp.StageName = 'Qualification' ;  
                 opp.CloseDate = + 14; 
                 opp.AccountId =[0].ConvertedAccountId;
               /* I have commented out the assignment statements for now. If I go with this way then every time a new field is added on to a lead then I have to update the trigger if we have to map it across to opportunity from Lead.
               opp.Xero_Payments__c =[0].Xero_Accept_Payments__c; 
                 opp.API_Requested__c =[0].API_Requested__c;
                 opp.Avg_Trans_Value__c =[0].Avg_Trans_Amount__c;
                 opp.BPAY_Required__c =[0].BPAY_Requested__c;  
                 opp.Console_Gateway__c =[0].Console_Gateway__c;
                 opp.Lead_Countries__c =[0].Lead_Countries__c;
                 opp.Current_Processor__c =[0].CurrentProcessor__c;
                 opp.Recurring_Required__c =[0].Direct_Debit_Requested__c;
                 opp.Real_Time_Required__c =[0].eCommerce__c;
                 opp.HPP_Requested__c =[0].HPP_Requested__c;
                 opp.Lead_Created_Date_and_Time__c =[0].  */
                 insert opp;

Best Answer chosen by Yamini Bathula
Yamini BathulaYamini Bathula
Hi Guys,

Just an Update on this. I found a work around for this. If any one has the same issue they can try this work around.A Validation Rule on Leads to Check the COnverted Opporutnity ID for null Value can force the user to enter name in the Opportunity Name field. This way we can make sure an Opportunity is created in Lead Conversion.
Here is the link explaining how to do this :

Validation Rule Formula on Leads:
AND(IsConverted=true, ConvertedOpportunityId="") .