You need to sign in to do that
Don't have an account?
Christopher Littlefield 6
How do I increase code coverage for this Apex Trigger
I believe I need a test for the following trigger that I am trying to deactivate, but my code coverage is too low. I'm desperate at this point because it is holding up an install.
trigger ConvertLeadToContact on Lead (after update) {
//cbl code to comment the trigger code 1/26- add this line and line below
/*
List<Lead> leadsToConvert = new list<Lead>();
for(Lead l: Trigger.new){
if(l.Program__c == 'SPHP')
if(!l.isConverted)
leadsToConvert.add(l);
}
Id acctId = null;
List<Account> acctList = [
SELECT Id
FROM Account
WHERE Name = 'CGPS Bucket' AND Program_Email__c = 'owladmissions@une.edu'
];
if (acctList.size() == 1)
acctId = acctList[0].Id;
LeadStatus convertStatus = [
SELECT Id,
MasterLabel
FROM LeadStatus
WHERE IsConverted = true
LIMIT 1
];
List<Database.LeadConvert> leadConverts = new list<Database.LeadConvert>();
for(Lead l : leadsToConvert){
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(l.Id);
lc.setConvertedStatus(convertStatus.MasterLabel);
lc.setDoNotCreateOpportunity(true);
lc.setAccountId(acctId);
leadConverts.add(lc);
}
if(!leadConverts.isEmpty()){
Database.LeadConvertResult[] lcrList = Database.convertLead(leadConverts, false);
for(Database.LeadConvertResult lcr : lcrList)
System.assert(lcr.isSuccess());
}
*/
//End of comment line code - add this line and also the line above which has */
}
trigger ConvertLeadToContact on Lead (after update) {
//cbl code to comment the trigger code 1/26- add this line and line below
/*
List<Lead> leadsToConvert = new list<Lead>();
for(Lead l: Trigger.new){
if(l.Program__c == 'SPHP')
if(!l.isConverted)
leadsToConvert.add(l);
}
Id acctId = null;
List<Account> acctList = [
SELECT Id
FROM Account
WHERE Name = 'CGPS Bucket' AND Program_Email__c = 'owladmissions@une.edu'
];
if (acctList.size() == 1)
acctId = acctList[0].Id;
LeadStatus convertStatus = [
SELECT Id,
MasterLabel
FROM LeadStatus
WHERE IsConverted = true
LIMIT 1
];
List<Database.LeadConvert> leadConverts = new list<Database.LeadConvert>();
for(Lead l : leadsToConvert){
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(l.Id);
lc.setConvertedStatus(convertStatus.MasterLabel);
lc.setDoNotCreateOpportunity(true);
lc.setAccountId(acctId);
leadConverts.add(lc);
}
if(!leadConverts.isEmpty()){
Database.LeadConvertResult[] lcrList = Database.convertLead(leadConverts, false);
for(Database.LeadConvertResult lcr : lcrList)
System.assert(lcr.isSuccess());
}
*/
//End of comment line code - add this line and also the line above which has */
}
Raj Vakati
Christopher Littlefield 6
Thanks, @RajV.