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
kpetersonkpeterson 

Can apex be fired when a Quote is synced?

When someone syncs a quote to an opportunity I need apex to be triggered so that I can copy values from quote line item custom fields to their related opportunity line item's custom fields.  Is there a trigger for this?

 

The only thing close to this that I've thought of is firing apex when an Opportunity is updated and checking if the "Synced Quote" field changed.  This would tell me that the opportunity was just recently synced but I won't have direct relationships from the opportunity line items to the originating quote line items to accurately copy values between them.

ahab1372ahab1372

I agree that you probably need a trigger on opportunity line items. Whenever the opp line items change and the opp is synced to a quote, you then have to query the quote line items that are attched to the quote and somehow match them to the opportunity line items.

If you have a unique identifier for your products (like a part number) you could use that to match quote line items to opportunity line items.You still might run into problems when you have different line items with the same part number (happens sometimes). Not sure if you want to build your own sync functionality to include your custom fields, but that might be an option. What kind of fields do you want to include?

 

I chose to create the whole quote thing on my own because the sfdc quotes did not realy match our needs. Syncing is only manually triggered and then it is easy, you just delete all the old opp line items and build new ones. For us there is not much value in the automatic syncing because quotes do not really change over time. They are created, then sent out and then they are locked. Any changes after it has been sent requires a new quote

Mitesh SuraMitesh Sura

Not sure if this solves your problem. 

Have a trigger on Quote, and check if its Old and New value for "IsSyncing". 

for(Quote q : Trigger.new){
	    	if(Trigger.oldMap.get(q.Id).IsSyncing==false && Trigger.newMap.get(q.Id).IsSyncing==true){
	    		oppIds.add(q.OpportunityId);
	    		quoteIds.add(q.Id);
	    	}
	    }

 if Old value is False and New value is True, that means the Quote was just set to Sync with the Opportunity. 

You have Opp and Quote Ids, within that loop. Build your logic based on that .. 

 

regards

SF Partner

 

RupaliJRupaliJ

Hi,

 

I want to access IsSync value in trigger. But, for both new and old trigger, I am getting false value. Can you please tell me why is it coming like this as I clicked on Start Sync button from Quote.

 

Thanks.

Mitesh SuraMitesh Sura

Rupali,

 

how are you syncing the quote? via code or UI? if you are doing via the code, safe bet would be Opportunity.SyncedQuoteId. 

 

SF Partner