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
jadenjaden 

OpportunityLineItem Trigger Issue

I have a before trigger based on OpportunityLineItem updating OpportunityLineItem.  I have a debug at the bottom of the trigger that displays the line map and it shows my discount field has been changed but the update is not getting applied. Below is the bulk of the trigger and below that is the debug log clip. 

 

 Any help appreciated! 

 

    system.debug('&&** THe OL Map before updates is ' + opplinemap); 
    system.debug('&&** THe acct map is ' + Acctmap); 
    system.debug('&&** THe Prod Map is ' + prodMAP);
 
    for(OpportunityLineItem ol : opplinemap.Values())
    {
        if(Prodmap.Containskey(ol.Pricebookentry.Product2id))
        {
            if(Prodmap.get(ol.Pricebookentry.Product2id).Family == 'SERVICES')
                if(Acctmap.get(ol.Opportunity.Accountid).Services_Discount__c != null)
                    ol.Discount__c =  Acctmap.get(ol.Opportunity.Accountid).Services_Discount__c;
            if(Prodmap.get(ol.Pricebookentry.Product2id).Family == 'SOFTWARE')
                if(Acctmap.get(ol.Opportunity.Accountid).Software_Discount__c != null)
                    ol.Discount__c =  Acctmap.get(ol.Opportunity.Accountid).Software_Discount__c;
            if(Prodmap.get(ol.Pricebookentry.Product2id).Family == 'HARDWARE')
                if(Acctmap.get(ol.Opportunity.Accountid).Hardware_Discount__c != null)
                    ol.Discount__c =  Acctmap.get(ol.Opportunity.Accountid).Hardware_Discount__c;

            //Now Update Opp flags 
            if(Prodmap.get(ol.Pricebookentry.Product2id).Product_Category__c == 'FoIP Software')
                oppmap.get(ol.Opportunityid).FoIP_Questionnaire__c = true;
            if(Prodmap.get(ol.Pricebookentry.Product2id).Product_Category__c == 'FOIP Software')
                oppmap.get(ol.Opportunityid).FoIP_Questionnaire__c = true;            
            if(Prodmap.get(ol.Pricebookentry.Product2id).Product_Category__c == 'Installation')
                oppmap.get(ol.Opportunityid).Installation_Document__c = true;
            if(Prodmap.get(ol.Pricebookentry.Product2id).Product_Category__c == 'Consulting Services')
                oppmap.get(ol.Opportunityid).PSP_Required__c = true;
            if(Prodmap.get(ol.Pricebookentry.Product2id).Product_Category__c == 'Professional Services')
                oppmap.get(ol.Opportunityid).SOW__c = true;
            	
        }    
    }
    
    system.debug('&&** Final OPP LINE MAP ' + opplinemap.Values());
    system.debug('&&** About to do update for these OPP ' + oppmap.Values());

 

11:05:18.806 (3806341000)|USER_DEBUG|[37]|DEBUG|&&** THe OL Map before updates is {006E000000BQVDgIAP=OpportunityLineItem:{OpportunityId=006E000000BQVDgIAP, PricebookEntryId=01uE0000003CcjrIAC, Id=00kE0000009IXEPIA4}}
11:05:18.806 (3806466000)|USER_DEBUG|[38]|DEBUG|&&** THe acct map is {001E000000cMLc8IAG=Account:{Services_Discount__c=10.00, Software_Discount__c=20.00, Hardware_Discount__c=30.00, Id=001E000000cMLc8IAG}}
11:05:18.806 (3806579000)|USER_DEBUG|[39]|DEBUG|&&** THe Prod Map is {01tE0000001MW22IAG=Product2:{Product_Category__c=Installation, Family=SERVICES, Id=01tE0000001MW22IAG}}
11:05:18.808 (3808090000)|USER_DEBUG|[70]|DEBUG|&&** Final OPP LINE MAP (OpportunityLineItem:{OpportunityId=006E000000BQVDgIAP, PricebookEntryId=01uE0000003CcjrIAC, Discount__c=10.00, Id=00kE0000009IXEPIA4})
11:05:18.808 (3808276000)|USER_DEBUG|[71]|DEBUG|&&** About to do update for these OPP (Opportunity:{PSP_Required__c=false, Installation_Document__c=true, Id=006E000000BQVDgIAP, FoIP_Questionnaire__c=false, SOW__c=false})
 
Thank you