You need to sign in to do that
Don't have an account?
Lakshmi S
How to Bulkify the Trigger ?
Hi Team,
How can we bulkify below trigger.
Thanks,
Regards.
How can we bulkify below trigger.
trigger CreateOpportunity on Task (after insert) { if(Trigger.isInsert && Trigger.isAfter){ Set<Id> taskid = new Set<Id>(); Map<Id, Task> taskmap = new Map<Id, Task>(); List<Opportunity> oppList = new List<Opportunity>(); Opportunity opp = Null; for(Task t : Trigger.New){ if(t.Sales_Outreach__c == 'Converted to New Opportunity' && t.WhatId == Null){ System.debug('----'+t.Subject+'---'+t.Id); taskid.add(t.Id); opp = new Opportunity(); opp.Name = t.Subject; opp.Lead_Country__c = 'India'; opp.Region__c = 'South'; opp.CloseDate = Date.newInstance(2018, 10, 20); opp.ForecastCategoryName = 'Best Case'; opp.StageName = 'Intro Meeting / Discovery'; opp.Category__c = 'Cultivation Targets'; //oppList.add(opp); } } if(opp != Null){ insert opp; } if(taskid.size() > 0){ Task t = [Select id from Task where id in :taskid limit 1]; t.WhatId = opp.Id; update t; } // t.WhatId = opp.Id; // update t; } }Please let me konw any one !!!
Thanks,
Regards.
Best Answer chosen by Lakshmi S
Steven Nsubuga
Try this