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;
                        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) {



        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) {                  

        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>());                



        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;

        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.

  • method should contains the parameters. UpdateTrigger(List<object> objList,Boolean flag). and same for insertTrigger method also. not direct values. values are passing from trigger. Nov 10 '16 at 11:38
  • @ShravanBoddula it's provide the following error is it correct as you say my trigger is followingly, trigger customSyncHandlerTrigger on QuoteLineItem (after Insert, after update) { if (Trigger.isInsert && Trigger.isAfter) { Boolean Iden; CustomSyncHandler.InsertTrigger(Trigger.New, Boolean Iden); } if (Trigger.isUpdate && Trigger.isAfter) { boolean Iden; CustomSyncHandler.UpdateTrigger(Trigger.New, Trigger.OldMap, boolean Iden); } }
    – MohanRaj
    Nov 10 '16 at 11:55
  • no, im talking in helper class it should be public static void InsertTrigger (List<QuoteLineItem> InsertedQuote, Boolean flag) { Nov 10 '16 at 11:59
  • @ShravanBoddula thank you so much I got your point pls show the answer for selecting yours as a best answer of my question.
    – MohanRaj
    Nov 10 '16 at 12:02

Method declaration contains the variables not values. it should be

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.