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
anthonymossit1.3956973255286362E12anthonymossit1.3956973255286362E12 

Lead Conversion Trigger Problem

The following trigger - convert lead to contents when custom field=Trigger - works perfectly in my Dev Org, but doesn't at all in my Sandbox or Production org.

It passes unit tests with 100% coverge - but it doesn't function, the lead does not convert to a contact. Any help would be appreciated. Thanks!

trigger ConvertLeadtrigger on Lead (after insert) {
//Bulkified
   Integer Count =0;
    Database.LeadConvert[] leadCollectionArray = new Database.LeadConvert[trigger.new.size()] ;
    for(Lead Lea : trigger.new){
        if(Lea.Convert__c == 'Trigger'){
          Database.LeadConvert convLead = new database.LeadConvert();
          convLead .setLeadId(Lea.Id);
          convLead.setConvertedStatus('Closed - Converted');
          convLead.setAccountID('001i000000gKtwA');
          convLead .setDoNotCreateOpportunity(true);
          leadCollectionArray[count] = convLead ;
          count++;
         }
    }
    Database.LeadConvertResult[] LeaConvResults = Database.convertLead(leadCollectionArray,false); 
}
SFDC_DevloperSFDC_Devloper
Hi,

   I hope below link help you!

http://blog.wdcigroup.net/2013/11/salesforce-apex-trigger-lead-conversion/



Thanks,
Rockzz