Skip to main content
Hi,

I am trying to write a trigger that updates a checkbox on Opportunity, when the status on all the related Opportunity products is Submitted, is should be done on all insert, updates, deletes, can any one advise on how to write the trigger. Thank you.
7 answers
  1. Jun 9, 2015, 2:54 PM
    I've updated the code, but still getting the following error

    Delete failed. First exception on row 0 with id 00on0000000bjq7AAA; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FulfillmentTrigger: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.FulfillmentTrigger: line 8, column 1: []

    trigger FulfillmentTrigger on OpportunityLineItem (after insert, after update, after delete) {

        

        for(OpportunityLineItem oppLI: Trigger.new){

            boolean B1 = true;

            boolean B2 = true;

            Opportunity opp = oppLI.Opportunity;

            List< OpportunityLineItem > oppLIo = [SELECT id, Fulfillment_Instructions_Status__c from OpportunityLineItem where Opportunity.Id = :opp.Id];

            for(OpportunityLineItem oli: oppLIo){

                //if//(CONTAINS(TEXT(oli.Fulfillment_Instructions_Status__c), 'QFF Submitted')*/){

                String test = oli.Fulfillment_Instructions_Status__c;

                if(test.contains('QFF Submitted')){

                    

                }else{

                

                    B1 = false;

                

                }

               

                if(test.contains('Case Created')){

                //if(String.CONTAINS(oli.Fulfillment_Instructions_Status__c, 'Case Created')){

                //if(1==1){

                    

                    

                }

                else{

                

                    B2 = false;

                

                }

                if(B1){

                opp.Fulfillment_Instructions_Complete__c = true;

                }

                if(B2){

                opp.Fulfillment_Cases_Created__c = true;

                }

                }

            }

        }