+ Start a Discussion
Marc C.Marc C. 

After Update Trigger, Triggers itself

We would like to callout to another system each time a contact person is created. This 3rd party system returns a value which we want to write into the contact person record. If we callout "after update" then, when we write the returned value, we re-trigger our own trigger again -> infinite circle.

 

Options:

1) We callout "before update"

2) We use fields on the contact to check whether the callout should run

3) We use some global static variable to flag whether the callout should run

 

Neither of these options is very satisfying for various reasons.

 

Is there any way to know that a trigger was called directly from the UI and not from some Apex code (e.g. the code inside the trigger)?

Jeff MayJeff May

Here is a link to controlling recursive triggers -- based on the 'context' of a trigger -- which might get you a pointer to an acceptable solution. http://www.salesforce.com/docs/developer/cookbook/Content/apex_controlling_recursive_triggers.htm

 

nbnb

Hi 

 

A helper class with a  boolean can be sufficient. set the code in sucha way that call will run only when the value is false.