+ Start a Discussion
David JobeDavid Jobe 

too many dml for creating an opportunity

I have built the below code. I got the too many DML statements, but I'm drawing a blank on how to bulkify this. 
Any help would be appreciated. 

trigger CreateOpportunity on Revenue_Marketing__c (after insert) {
    for (Revenue_Marketing__c acc :Trigger.new) {
        Opportunity app                             = new Opportunity();
        app.ARVACT__c                                   = acc.ARVACT__c;
        app.tel_business__c                             = acc.Business_Phone__c;
        app.Call_Date__c                                = acc.Call_Date__c;
        app.tel_home__c                                 = acc.Home_Phone__c;
        app.FirstName__c                                = acc.First_Name__c;
        app.LastName__c                                 = acc.Last_Name__c;
        app.LastPurchaseDate__c                         = acc.Last_Purchase_Date__c;
        app.OwnerLevel__c                               = acc.Owner_Level__c;
        app.Points__c                                   = acc.Points__c;
        app.Rep_Assigned__c                             = acc.Rep_assignment__c;
        app.Address1__c                                 = acc.Address__c;
        app.State__c                                    = acc.State__c;
        app.zip_code__c                                 = acc.Zip__c;
        app.StageName                                   ='Prospecting';
        app.Name                                        = acc.Last_Name__C+date.today();
        app.CloseDate                                   = date.Today()+14;
        insert app;
    }
}
Raj VakatiRaj Vakati
trigger CreateOpportunity on Revenue_Marketing__c (after insert) {

List<Opportunity> opp = new List<Opportunity>(); 
    for (Revenue_Marketing__c acc :Trigger.new) {
        Opportunity app                             = new Opportunity();
        app.ARVACT__c                                   = acc.ARVACT__c;
        app.tel_business__c                             = acc.Business_Phone__c;
        app.Call_Date__c                                = acc.Call_Date__c;
        app.tel_home__c                                 = acc.Home_Phone__c;
        app.FirstName__c                                = acc.First_Name__c;
        app.LastName__c                                 = acc.Last_Name__c;
        app.LastPurchaseDate__c                         = acc.Last_Purchase_Date__c;
        app.OwnerLevel__c                               = acc.Owner_Level__c;
        app.Points__c                                   = acc.Points__c;
        app.Rep_Assigned__c                             = acc.Rep_assignment__c;
        app.Address1__c                                 = acc.Address__c;
        app.State__c                                    = acc.State__c;
        app.zip_code__c                                 = acc.Zip__c;
        app.StageName                                   ='Prospecting';
        app.Name                                        = acc.Last_Name__C+date.today();
        app.CloseDate                                   = date.Today()+14;
        opp.add(app);
    }
	
	if(opp.size()>0){
	insert opp ; 
	}
}