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
kfridaykfriday 

When cloning an Opportunity with Products should the OpportunityLineItem Trigger get executed?

Hi Everyone,

Can someone please tell me when cloning an 'Opportunity with Products' should the 'OpportunityLineItem before update or insert Trigger' get executed?
It appears that the OpportunityLineItem trigger is NOT firing when I clone a 'Opportunity with Products'. I can tell because the SalesPrice is not being calculated correctly which should occur when the Trigger executes and calls the apex class that does the calculation. Thanks.
Best Answer chosen by kfriday
Jake BackuesJake Backues
When cloning any Object the trigger contexts that fire are the before and after Insert contexts. Not the Update contexts. If you open your triggers and look for the one containing these contexts that will be the trigger that is firing.

You could also test this by having some debugs at the beginning of your trigger classes stating which class you have arrived at.

All Answers

Jake BackuesJake Backues
When cloning any Object the trigger contexts that fire are the before and after Insert contexts. Not the Update contexts. If you open your triggers and look for the one containing these contexts that will be the trigger that is firing.

You could also test this by having some debugs at the beginning of your trigger classes stating which class you have arrived at.
This was selected as the best answer
kfridaykfriday
Thanks Jake, I added debug msgs and indeed found the update trigger was firing, it just wasn't obvious with the various flags I had in the code whether the SalesPrice had been touched. Turned out one of the flags was not being reset when bulk items were being updated, a situation I had not considered.