[SalesForce] How to pass the boolean value from the trigger

I am done the trigger for now insert and update for the Quote Line item to the Opportunity Line item as folloowingly My trigger is,

trigger customSyncHandlerTrigger on QuoteLineItem (after Insert, after update, boolean) {
    if (Trigger.isInsert && Trigger.isAfter) {
        CustomSyncHandler.InsertTrigger(Trigger.New, True);
    }
    if (Trigger.isUpdate && Trigger.isAfter) {
        CustomSyncHandler.UpdateTrigger(Trigger.New, Trigger.OldMap, False);
    }
}

and My handler class is,

public class CustomSyncHandler {

    public static void InsertTrigger (List<QuoteLineItem> InsertedQuote, True ) {
        List<Id> ProductIDList = new List<Id>();
        List<Id> QuoteIDList = new List<Id>();
        List<Id> OpportunityIDList = new List<Id>();
        List<OpportunityLineItem> OpportunityLineItemList = new List<OpportunityLineItem>();
        List<QuoteLineItem> QuoteLinItemList = new List<QuoteLineItem>();
        List<OpportunityLineItem> OpportunityLILIST = new List<OpportunityLineItem>();

        for (QuoteLineItem QLIRecords : InsertedQuote) {
            ProductIDList.add (QLIRecords.Product2Id);
            QuoteIDList.add (QLIRecords.QuoteId);
        }
        system.debug(' ProductIDList value is --->'+ProductIDList);
        system.debug(' QuoteIDList value is ---->'+QuoteIDList);

        if (QuoteIDList.size() > 0 && ProductIDList.size() > 0) {
            QuoteLinItemList = [SELECT Id, Product2Id, Quote.isSyncing, QuoteLineItemTextArea__c, Quote.OpportunityId, QuoteId FROM QuoteLineItem WHERE Product2Id IN :ProductIDList AND Quote.issyncing = True  ];
        }
        system.debug('QuoteLinItemList value is --->'+QuoteLinItemList);

        for (QuoteLineItem quoterec : QuoteLinItemList ) {
            OpportunityIDList.add (quoterec.Quote.OpportunityId);
        }
        system.debug('QuoteLinItemList value is ---->'+QuoteLinItemList);

        if (OpportunityIDList.size() > 0) {
        OpportunityLineItemList = [SELECT Id, OpportunityId, Product2Id, OpportunityProducttextArea__c FROM OpportunityLineItem WHERE OpportunityId IN:OpportunityIDList AND Product2Id IN :ProductIDList ]; 
        }
        system.debug('OpportunityLineItemList value is ---->'+OpportunityLineItemList);

        Map<Id, List<OpportunityLineItem>> OpporAndOpportunityLIMap = new Map<Id, List<OpportunityLineItem>>();
        for (OpportunityLineItem OpportunityLIRec : OpportunityLineItemList) {
            if (!OpporAndOpportunityLIMap.containsKey(OpportunityLIRec.OpportunityId)) {
                OpporAndOpportunityLIMap.put (OpportunityLIRec.OpportunityId , new List<OpportunityLineItem>());
            } 
            OpporAndOpportunityLIMap.get (OpportunityLIRec.OpportunityId).add (OpportunityLIRec);
        }
        system.debug('OpporAndOpportunityLIMap value is ----> '+OpporAndOpportunityLIMap);


        for (QuoteLineItem QuoteLIREC : QuoteLinItemList) {
system.debug('<---------PASS 1------------->');        
            if (OpporAndOpportunityLIMap.containsKey(QuoteLIREC.Quote.OpportunityId)) {
system.debug('<-----PASS 2----------->');            
                for (OpportunityLineItem OpporLIREC : OpporAndOpportunityLIMap.get(QuoteLIREC.Quote.OpportunityId)) {
system.debug('<-----PASS 3---------->');                
                    if (OpporLIREC.Product2Id == QuoteLIREC.Product2Id) {
                    system.debug('<-----PASS 4--------->');
                        OpporLIREC.OpportunityProducttextArea__c = QuoteLIREC.QuoteLineItemTextArea__c;
                        OpportunityLILIST.add(OpporLIREC);
                        system.debug('OpportunityLILIST value is ---->'+OpportunityLILIST);
                    }
                } 
            }                        
        }

        if (OpportunityLILIST.size() > 0) {
            Update OpportunityLILIST;
        }

    }   

    public static void UpdateTrigger (List<QuoteLineItem> InsertedQuote, Map<Id,QuoteLineItem> OldInsertedQuoteMap, False) {

        Set<Id> ProductIdset = new Set<Id>();
        Set<Id> QuoteIdset = new Set<Id>();
        Set<Id> OpportunityIdset = new Set<Id>();
        List<QuoteLineItem> QuoteLineItemList = new List<QuoteLineItem>();
        List<OpportunityLineItem> OpportunityLineItemList = new List<OpportunityLineItem>();

        for (QuoteLineItem RecordQuoteItem: InsertedQuote) {

           QuoteLineItem OldQuoteLineItemREC = OldInsertedQuoteMap.get(RecordQuoteItem.Id);

           if (OldQuoteLineItemREC.QuoteLineItemTextArea__c != RecordQuoteItem.QuoteLineItemTextArea__c) {

               ProductIdset.add(RecordQuoteItem.Product2Id);
               QuoteIdset.add(RecordQuoteItem.QuoteId); 
           }               

        }

        If (QuoteIdset.size()>0) {

            QuoteLineItemList = [SELECT Id, QuoteId, Product2Id, QuoteLineItemTextArea__c, Quote.issyncing, Quote.OpportunityId FROM QuoteLineItem WHERE Product2Id IN :ProductIdset AND Quote.issyncing = True  ];
        }

        If (QuoteLineItemList.size() > 0) {

            for (QuoteLineItem quoteLineitemvalue: QuoteLineItemList) {                  
                OpportunityIdset.add(quoteLineitemvalue.Quote.OpportunityId);                       
            }
        }

        List<OpportunityLineItem> OpportunityLineitemvalueList = [SELECT Id, Name, OpportunityId, OpportunityProducttextArea__c, Product2Id FROM OpportunityLineItem WHERE OpportunityId IN :OpportunityIdset AND Product2Id IN :ProductIdset];

        Map<Id, List<OpportunityLineItem>> OpportunityandOppolineitemMap = new Map<Id, List<OpportunityLineItem>>();

        for (OpportunityLineItem OpportunityLIRecord : OpportunityLineitemvalueList) {

            If (!OpportunityandOppolineitemMap.Containskey(OpportunityLIRecord.Id)) {

                OpportunityandOppolineitemMap.put(OpportunityLIRecord.OpportunityId, new List<OpportunityLineItem>());                
             } 

                 OpportunityandOppolineitemMap.get(OpportunityLIRecord.OpportunityId).add(OpportunityLIRecord);

        }

        system.debug('@@@ OpportunityandOppolineitemMap value is'+OpportunityandOppolineitemMap);

        for (QuoteLineItem QuoteLineItemRecord : QuoteLineItemList) { 

            if (OpportunityandOppolineitemMap.containsKey(QuoteLineItemRecord.Quote.OpportunityId)) {  

                 for (OpportunityLineItem OpporVar : OpportunityandOppolineitemMap.get(QuoteLineItemRecord.Quote.OpportunityId)) {

                     if (OpporVar.Product2Id == QuoteLineItemRecord.Product2Id) {

                         OpporVar.OpportunityProducttextArea__c = QuoteLineItemRecord.QuoteLineItemTextArea__c;
                         OpportunityLineItemList.add(OpporVar);

                     }
                 }          
            }        
        }
        if (OpportunityLineItemList.size() > 0) {

            Update OpportunityLineItemList;  

        }          
    }
}

Like above it's provide the error

variable doesn't exit and method doesn't exit on the provided boolean value

I am a newbie for the trigger with passing parameter so please help me to done this function. I am trying to following like,

I pass the boolean parameter if the value of the boolean is false it's represents the insert trigger to execute.

And if the boolean is false it's represents the Update trigger. the boolean value is decide the insert/update of the event of the trigger.

this is I am trying to and my requirement also so help to done this for answer thanks in advance.

Best Answer

Method declaration contains the variables not values. it should be

public static void InsertTrigger (List<QuoteLineItem> InsertedQuote, **Boolean flag**) { 

}
Related Topic