+ Start a Discussion
Deepti Maheshwari 3Deepti Maheshwari 3 

In what order do triggers fire during Quote Sync Process

I am trying to do a one way sync from Quote to opportunity(Line Items included, standard and custom fields also). I have created triggers on opportunity and opportunity line item for the same. When 'Sync Quote' button is clicked from quote page it calls opportunity trigger and in the background quote trigger is called. In opportunity trigger I update line items also which then gives and error

Apex trigger IS_OpportunityTrigger caused an unexpected exception, contact your administrator: IS_OpportunityTrigger: execution of BeforeUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id 00kq0000002du0uAAA; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 006q0000005Lw5i) is currently in trigger IS_OpportunityTrigger, therefore it cannot recursively update itself: []: Class.IS_OpportunityTriggerHandler.syncQuoteAndOpportunityCustomFields: line 302, column 1

I want to know in what order triggers are called on opportunity, opportunity Line items, quote and quoteLineItems? I have also observed that sometimes line items are deleted and new ones created and sometimes it updates the existing line item. How does salesforce determine which action has to be performed in this sync process?
Anup JadhavAnup Jadhav
Just to clarify, how do you actually "call" the Opp trigger from the sync quote button. Perhaps a code snippet will enable us to provide more insight.
Deepti Maheshwari 3Deepti Maheshwari 3
I do not explicitly call opportunity trigger, When sync is started system sets 'SyncedQuoteID' on opportunity and I have seen the calls of opportunity methods in the logs