You need to sign in to do that
Don't have an account?
Lindsey Colvin2
Quote Line Item Trigger to call a class
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?
Any help is appreciated!
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!
One thing to note about this, if "doSynchToQuote" is doing any DML operations, you could quickly exhaust your governor limits because you are operating inside of a loop. If it does, I would suggest that you reach out to whomever owns the vlocity_cmt package and see if they have a bulk ready way to do what that method does.
Thoughts on this?
Can you tell me which line the NullPointerException is occuring? You should have an error that shows a bunch more information.
This code won't get rid of the too many SOQL errors if the vlocity_cmt stuff is the culprit. This still uses it inside of a loop which has the same issue. And if you want the sync to happen when the QuoteLineItem is updated and rolled up to the Quote, then this trigger may never happen if the Quote object isn't updated. It would be better to do it on the QuoteLineItem and find a way with vlocity_cmt to handle the bulk usecase.