function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
trigger LeadConvert on Lead (after update)
{
Map<String, Lead> leadMap = new Map<String, Lead>();
if(contEmailSet.size() > 0)
{
for(Lead leadObj: [Select Id, Name, Email, isConverted from Lead Where Email in: contEmailSet])
{
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(leadObj.Id);
lc.setAccountId(contMap.get(leadObj.Email).AccountId);
lc.setContactId(contMap.get(leadObj.Email).Id);
lc.setDoNotCreateOpportunity(true);
LeadStatus convertStatus = [SELECT Id, MasterLabel, IsConverted FROM LeadStatus WHERE IsConverted=true limit 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
try
{
Database.LeadConvertResult lcResults = Database.convertLead(lc);
}Catch(Exception exp)
{
contMap.get(leadObj.Email).addError(exp.getMessage());
}
}
}
}