function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GMASJGMASJ 

QuoteLines are not getting updated from Quote Trigger

Hi, 
 
 I am trying to update quoteline fields from quote using a trigger and helper class it is not getting updated I am not get getting any error please suggest me what is the issue in below code. 

Trigger
trigger QuoteTrigger on Quote (before  insert, Before Update, After Insert) {

   if(Trigger.isAfter && Trigger.isInsert){
      system.debug('After update calling...');
      QuoteTriggerUtils.updateQlineDecimals(Trigger.new); 
    } 

}
Helper Class 
public static void updateQlineDecimals(List<Quote> qList){
        List<id> QtIds = new List<id>();
        List<QuoteLineItem> Qtlinlst = new List<QuoteLineItem>();        
        for(Quote quote:qList){
            QtIds.add(quote.id);
        }       
        List<QuoteLineItem> Qtlines = [select id, Reseller_Discount__c, Disti_Discount__c from QuoteLineItem where quoteid in :QtIds];
        
        for(QuoteLineItem Qtl : Qtlines){        
          //Qtl.Disti_Discount__c = String.Valueof(Decimal.Valueof(Qtl.Disti_Discount__c).setscale(2));
          //Qtl.Reseller_Discount__c = String.Valueof(Decimal.Valueof(Qtl.Reseller_Discount__c).setscale(2));
          system.debug('Disti Discount  ' + Qtl.Disti_Discount__c);
          system.debug('Reseller Discount ' + Qtl.Reseller_Discount__c);
          Qtl.Disti_Discount__c = '1';
          Qtl.Reseller_Discount__c = '2';
          Qtlinlst.add(Qtl);
         }        
         update Qtlinlst;
    }
Thanks
Sudhir
 
Dmitry OfitserovDmitry Ofitserov
Hi GMASJ,
I can see that your handler class is only called from after insert operation on Quote. Does the Quote have line items at this point ?

Thanks,
Dmitry
ManojjenaManojjena
Hi GMASJ,

Your trigger is on after insert ,You are quering from Quote LineItem which is th echild object of Quote .At the time of inertion you wil not get any lin e item . Please explain your requirmnet clarly so that we can hlep you .

Thanks 
Manoj
GMASJGMASJ
Thanks for you reply, My requirement is when new quote is created Disti Discount and Reseller fields are not adding decimal value I need to add decimal value to the quote line items Please suggest me a logic to implement this change. 


Thanks
Sudhir