Skip to main content
Nishant Shrivastava (Statkraft) 님이 #Apex에 질문했습니다
My first system.debug is showing null value and i am not able to understand, what is wrong in it. my trigger is not working. kindly let me know. thanks :)

Trigger :

trigger SumQuote on QuoteLineItem (before delete) {

    if (trigger.isbefore && trigger.isdelete){

            SumQuoteHandler.sumQuotefeld(trigger.new);

        }

    }

Apex Class : 

public class SumQuoteHandler {

    Public static set<Id> ids;

    Public static List<Quote> QI = New List<Quote>();

    Public static List<QuoteLineItem> QLI = New List<QuoteLineItem>();

    

    Public Static void sumQuotefeld(List<QuoteLineitem>QLISUM){

        set<Id> ids = new set<Id>();

        for(QuoteLineItem QLII : QLISUM){

            Ids.add(QLII.QuoteId);

        }

        system.debug(ids);

        List<Quote> QI = [SELECT Id, Rabatt_der_einmaligen_Geb_hren__c, einmalige_Geb_hren__c, monatlicher_LP_Lizenzen__c  FROM Quote where Id IN:ids];

        system.debug(QI);

        List<QuoteLineItem> QL = [SELECT id, QuoteId FROM QuoteLineItem WHERE Id IN: Ids ];

        system.debug(QL);

        for (Quote Q : QI){

            for(QuoteLineItem QQ : QL){

                if(Q.id==QQ.QuoteId && QQ.QuoteId!=null && QQ.Produktkategorie__c=='Software Subscription'){

                          Q.Rabatt_der_einmaligen_Geb_hren__c = Q.Rabatt_der_einmaligen_Geb_hren__c-QQ.Euro_Rabatt_del__c;

                        Q.einmalige_Geb_hren__c = Q.einmalige_Geb_hren__c-QQ.GesamtpreisNEU__c;

                }

                else if(QQ.QuoteId==Q.id && QQ.QuoteId!=null && QQ.Produktkategorie__c=='Software'){

                    Q.monatlicher_LP_Lizenzen__c = Q.monatlicher_LP_Lizenzen__c-QQ.ListPrice;

                }

            }

        }

        update QI;

        system.debug(QI);

}

}

I shall be grateful to you for your valuable feedback. Thanks :)
답변 5개
  1. 2020년 7월 21일 오전 1:25
    Save as Ids, you have static property defined:

     Public static List<Quote> QI = New List<Quote>();

    and local variable:

    List<Quote> QI = [SELECT Id, Rabatt_der_einmaligen_Geb_hren__c, einmalige_Geb_hren__c, monatlicher_LP_Lizenzen__c  FROM Quote]; // where Id IN:ids

    You need to Remove unneccessary static properties.
0/9000