Skip to main content
I'm in need of some help.  I'm writing a trigger on Quote Line Item with intent to call a class to fire (the class will sync the line items back to the Opportunity) any time there is an after update on a Quote Line Item where the Quote's Primary_Quote__c checkbox == true.  Here is the code that I have currently.  It appears according to the debug that it is not returning the QLI ids.  Can someone please help steer me in the right direction?

 

trigger QuoteLineItem_Trigger on QuoteLineItem (after Update)

{

ApexPages.StandardController stdController;

public string currentRecordId {get; set;}

set<id> quoteIds = new set<id>();

if(trigger.isAfter && trigger.isUpdate) {

system.debug('%%%%%%%%%%% Entering the After Update on Quote');

for(QuoteLineItem QLI : trigger.new){

if( QLI.Quote!=NULL && QLI.Quote.Primary_Quote__c == true ) {

system.debug('%%%%%%%%%%% Not finding the right Quote');

ApexPages.StandardController controller = new ApexPages.StandardController(QLI.Quote);

system.debug('%%%%%%%%%%% +controller');

vlocity_cmt.LineItemManagementController stdcontroller = new vlocity_cmt.LineItemManagementController(controller);

stdcontroller.doSynchToQuote();

system.debug('%%%%%%%%%%% This is not syncing');

}

}

}

}

Any help is appreciated!  
5 个回答
  1. 2017年6月2日 17:05
    Ok, I tried moving this to the Quote object, instead of QLI.  It now works for any changes to existing line items!  However, when I try to insert a new line item, I get Apex trigger Quote_Trigger caused an unexpected exception, contact your administrator: Quote_Trigger: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object.  Here is what I have:

     

    trigger Quote_Trigger on Quote(after update) {

    Set<Id> quoteIds = new Set<Id>();

    for (Quote quo : Trigger.new) {

    quoteIds.remove(null);

    if ( quo!=NULL && quo.Primary_Quote__c == true ) {

    ApexPages.StandardController stdController = new ApexPages.StandardController(quo);

    vlocity_cmt.LineItemManagementController controller = new vlocity_cmt.LineItemManagementController(stdController);

    controller.doSynchToQuote();

    }

    }

    }

    Thoughts on this?