You need to sign in to do that
Don't have an account?

convert lead to oppurtunity
hiii ,
please help me with this code
trigger Lead_Opp on Lead (after insert) {
List<Opportunity> contact = new Opportunity[0];
List<Lead>lead=[SELECT Id, status ,name FROM lead WHERE Id in :Trigger.new];
for(Lead a: Trigger.new)
{
if(a.status!=null)
{
// contact.add(new Opportunity(Name ='anil',CloseDate=System.today(),stagename='qualification'));
// a.test_field__c='OKnott';
Database.LeadConvert lc = new database.leadconvert();
lc.setLeadid(a.id);
lc.setConvertedStatus('');
// Database.LeadConvertResult lcr = Database.convertLead(lc);
}
else
{
System.debug('fsdfds');
// a.test_field__c='OK';
}
}
insert contact;
}
iam getting error please help me.
I'd imagine that you get an error that the contact list doesn't contain any opportunities, as you initialize it to a single element but don't actually add any opportunities.