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
Tom in NYTom in NY 

Prevent trigger

I have an external web service I need to call when a quote is created/updated/deleted. I have a trigger on Quote and call my web service to add the quote to an external DB. The Quote trigger passes all the product information to the web service. I also have insert/update/delete triggers on QuoteLineItem that call out to web services to update the data in the external DB. The problem is I need to prevent the QuoteLineItem triggers from firing when the quote is new and trigger when the quote is not new.

 

I was thinking of having only triggers on Quote and not QuoteLineItem and pass the Quote and QuoteLineItem line information and then have the web service compare what is coming in to what was previously saved.

 

What’s the best way to handle this?

 

Thanks for your input

Tom

Best Answer chosen by Admin (Salesforce Developers) 
logontokartiklogontokartik

Add a static boolean flag that manages the trigger execution and check in the trigger before you actual logic. Set the flag to false if (trigger.isInsert) and to true if trigger.isUpdate

 

There are some real good posts regarding controlling triggers -

 

Try the url - http://www.tgerm.com/2012/01/salesforce-apex-trigger-template.html

 

 

All Answers

logontokartiklogontokartik

Add a static boolean flag that manages the trigger execution and check in the trigger before you actual logic. Set the flag to false if (trigger.isInsert) and to true if trigger.isUpdate

 

There are some real good posts regarding controlling triggers -

 

Try the url - http://www.tgerm.com/2012/01/salesforce-apex-trigger-template.html

 

 

This was selected as the best answer
Tom in NYTom in NY

Thanks Kartik, I was doing (or least trying to) do the same thing with the flag but I was not doing it correctly. The link in your post help me realize that.  I have only been doing salesforce for a week with no training so I am learning as I go.

 

Thanks again

Tom