Skip to main content
fixed code formatting
Source Link
Derek F
  • 64.1k
  • 15
  • 55
  • 104

I have the following Trigger but how do I write a Test for this so I can put it into production?

trigger web2LeadConvert on Lead (after insert) {
Database.LeadConvert[] converts = new Database.LeadConvert[0];
for(Lead record: Trigger.new) {
    if(record.Web_To_Lead__c == 'Yes') {
        Database.LeadConvert thisLead = new Database.LeadConvert();
        thisLead.setLeadId(record.Id);
        thisLead.setConvertedStatus('Qualified');
        converts.add(thisLead);
    }
}
Database.convertLead(converts);
}
trigger web2LeadConvert on Lead (after insert) {
    Database.LeadConvert[] converts = new Database.LeadConvert[0];
    for(Lead record: Trigger.new) {
        if(record.Web_To_Lead__c == 'Yes') {
            Database.LeadConvert thisLead = new Database.LeadConvert();
            thisLead.setLeadId(record.Id);
            thisLead.setConvertedStatus('Qualified');
            converts.add(thisLead);
        }
    }
    Database.convertLead(converts);
}

Thanks!

I have the following Trigger but how do I write a Test for this so I can put it into production?

trigger web2LeadConvert on Lead (after insert) {
Database.LeadConvert[] converts = new Database.LeadConvert[0];
for(Lead record: Trigger.new) {
    if(record.Web_To_Lead__c == 'Yes') {
        Database.LeadConvert thisLead = new Database.LeadConvert();
        thisLead.setLeadId(record.Id);
        thisLead.setConvertedStatus('Qualified');
        converts.add(thisLead);
    }
}
Database.convertLead(converts);
}

Thanks!

I have the following Trigger but how do I write a Test for this so I can put it into production?

trigger web2LeadConvert on Lead (after insert) {
    Database.LeadConvert[] converts = new Database.LeadConvert[0];
    for(Lead record: Trigger.new) {
        if(record.Web_To_Lead__c == 'Yes') {
            Database.LeadConvert thisLead = new Database.LeadConvert();
            thisLead.setLeadId(record.Id);
            thisLead.setConvertedStatus('Qualified');
            converts.add(thisLead);
        }
    }
    Database.convertLead(converts);
}

Thanks!

Source Link

Test Trigger Auto Convert Lead To Contact

I have the following Trigger but how do I write a Test for this so I can put it into production?

trigger web2LeadConvert on Lead (after insert) {
Database.LeadConvert[] converts = new Database.LeadConvert[0];
for(Lead record: Trigger.new) {
    if(record.Web_To_Lead__c == 'Yes') {
        Database.LeadConvert thisLead = new Database.LeadConvert();
        thisLead.setLeadId(record.Id);
        thisLead.setConvertedStatus('Qualified');
        converts.add(thisLead);
    }
}
Database.convertLead(converts);
}

Thanks!