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
SarikaPSarikaP 

How to avoid duplicate T&C records created because of Cloning Opps/Quotes as well as because of trigger placed on Quotelineitem?

Hello,

I am facing an issue while Cloning Opps & Quotes, reason being I am adding a special T&C only if they select certain kind of product with specific duration. So its runtime determined whether I will be adding T&C to the quote.
Now the issue is suppose the quote has those special T&C's, now when I am cloning the opp/ cloning the quote, it clones T&C's too, which is fine.
But during cloning there is an event on quotelineitem after insert which runs my trigger on quotelineitem that checks if a specific product is inserted with specific duration then insert the special T&C.
So in the end I am recieving duplicate T&C's in the quote.
How can I indicate the trigger that's fired on insert of Quotelineitem, that its a clone action, so this time at the time of insertion don't fire.
Whereas the trigger at quotelineitem can be fired while update/delete.

Thanks in advance!
sfdc expert 3sfdc expert 3
Hi Sarika,

In Your Quote Line Item Trigger you Can a put condition Like
 
for(QuoteLineItem qle : Trigger.new){

    if(qle.isclone() == false){
        // Execute the code of your after Insert if the Quote Line Item is not Inserted 
	    // by performing clone 
	}
	
}

Thanks
SarikaPSarikaP
That's not working :(
SarikaPSarikaP
Again Cloning of an Opp and Quote is the custom code that's been developed in the backend