View

Wednesday, May 1, 2013

Apex Coding on Convert to Opportunities / Class / Trigger.....


public class ConverttoOpportunities1
{
public static void Opptrigger(Lead[] lead)
{
 for (Lead l:lead)
 {
 if (l.Status == 'Approved')
 {
       List<Opportunity> opp= new List<Opportunity>();
        Date obj = Date.today();
        //for(integer i = 0; i < 1; i++)
       // {
            opp.add(new Opportunity(Name= l.LastName,CloseDate=obj , StageName = 'Qualification',OwnerId=l.OwnerID));
       // }
        insert opp;
 }
 }
}
}

--------------------------------------------------------------------------------------------------------


public class ConverttoOpportunities1
{
public static void Opptrigger(Lead[] lead)
{
 for (Lead l:lead)
 {
 if (l.Status == 'Approved')
 {
       List<Opportunity> opp= new List<Opportunity>();
        Date obj = Date.today();
        //for(integer i = 0; i < 1; i++)
       // {
            opp.add(new Opportunity(Name= l.LastName,CloseDate=obj , StageName = 'Qualification',OwnerId=l.OwnerID));
       // }
        insert opp;
 }
 }
}
}

------------------------------------------------------------------------------------------------------------


trigger ConvertLead on Lead(after insert)
    {
          Lead[] l= Trigger.new;
          ConverttoOpportunities.Opptrigger(l);
  }




No comments:

Post a Comment

Share your Comments .............