
check this one also...
trigger qlitem on QuoteLineItem (after insert, after update) {
List<opportunity> opl=new List<opportunity>();
public static double total=0;
List<quotelineitem> qlil=new List<quotelineitem>();
Quote Q=new Quote();
Opportunity opp=new Opportunity();
for(quotelineitem qli:trigger.new){
//qlil.add(qli);
Q= [Select id,opportunityid ,grandtotal,totalprice,primary__c from quote where id=:qli.quoteid];
opp=[Select id, amount from Opportunity where id=:q.opportunityid];
}
for(integer i=0;i<qlil.size();i++){
total=total+qlil[i].TotalPrice;
}
if(q.primary__c){
//This logic is used for updating the amount of opportunity with quote total price
Opp.amount=q.totalprice+total ;
}
opl.add(opp);
update opl;
}
3 个回答