You need to sign in to do that
Don't have an account?
Elizabete Fonseca
Sync Quote through apex class deleting Opportunity Line Items
Hi there!
I'm trying to automate the sync on Quote creation through apex code and I am able to sync the Opportunity with the Quote BUT instead of syncing OpportunityLineItems and QuoteLineItems, it's deleting the OpportunityLineItems from the Opportunity.
Does anyone knows how to auto-sync but avoid deletion of OpportunityLineItems?
Here's the code:
I'm trying to automate the sync on Quote creation through apex code and I am able to sync the Opportunity with the Quote BUT instead of syncing OpportunityLineItems and QuoteLineItems, it's deleting the OpportunityLineItems from the Opportunity.
Does anyone knows how to auto-sync but avoid deletion of OpportunityLineItems?
Here's the code:
insert quote; if(autosync){ opportunity.SyncedQuoteId = quote.Id; update opportunity; }
Cheers,
EF
Please use below approach to achieve it.
Hope this helps!!!
Thanks,
Gaurav
Skype: gaurav62990
Thanks for your response, but it did not work for me because...
- IDs don't have constructors, so this won't work: - and if I changed to this: or this: also does not work, since it doesn't seem like this method exists - setSyncedQuoteId().
Did you try this and it worked? Would you be able to share?
Appreciated :)
Best regards
EF
This error hapens because when you create a quote via apex, it does't bring the products from the opportunity automatically.
So, when you synchronize the quote with the opportunity, it clears the opportunity products because the quote has no items.
However, in manual creation, it already brings all items manually.
To solve this, you must create the quote line items via apex too.
Best Regards!
Bruno