You need to sign in to do that
Don't have an account?
multiple query bulkification trigger
this is the trigger i have written i know bulkification for singl queries but i am still confused for multiple query bulkification of trigger please check my trigger and give me bulkification code for it
trigger CreateCloneScheduleRevenue on OpportunityLineItem (after update)
{
public list<Custom_Revenue_Schedule__c > n1 {get;set;}
n1 =new list<Custom_Revenue_Schedule__c >();
set<id> pricebookid=new set<id>();
set<id> oliid=new set<id>();
id opp;
for(opportunitylineitem ols:trigger.new)
{
pricebookid.add(ols.pricebookentryid);
oliid.add(ols.id);
opp=ols.opportunityid;
}
pricebookentry pbe=[select id,Product2Id from pricebookentry where id=:pricebookid];
product2 p2=[select id from product2 where id=:pbe.product2id];
Custom_Revenue_Schedule__c[] c=[select id from Custom_Revenue_Schedule__c where Product__c=:p2.id];
if(c.size()>0)
{
delete c;
}
opportunitylineitemschedule[] olsc=[select id,Quantity,Revenue,ScheduleDate from opportunitylineitemschedule where opportunitylineitemid=:oliid];
for(opportunitylineitemschedule olsc1:olsc)
{
Custom_Revenue_Schedule__c c1=new Custom_Revenue_Schedule__c();
c1.Schedule_Revenue__c=olsc1.Revenue;
c1.Date__c=olsc1.ScheduleDate;
c1.Opportunity__c=opp;
c1.Product__c=p2.id;
n1.add(c1);
}
insert n1;
}
Is this trigger gives you any Error while upload multiple record
plz share the error it whold me much more help ful
i am not getting error but this is not a bulkified trigger i want to know how this can be bulkified
u can have follwing error with this trigger
2 Many Script Statement
OR DML lst can update uptp 10000 records at once
As u r inserting Custom_Revenue_Schedule__c form this trigger if any tirgger is persent on this obj it also run under this trigger instance
so it would he grate if u can share u error
You must use IN clause here. Make sure to use collection properly while dealing with Bulk Triggers.