You need to sign in to do that
Don't have an account?

Check if Trigger is called from Apex Class
Hi All,
I want to ask is it possible to check in trigger if the trigger is called from other apex class? The apex class is not future method.. I want to avoid trigger call if called from apex class only..
Any suggestions would be great..
Thanks...
set up a static variable and set it in the class. check it in the trigger.
If it doesn't really matter which Class it's coming from, as long as it's a class and not an API call, you can use the isExecuting context variable.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables.htm
if the class inserts a record and causes the trigger to fire, would isExecuting be = true?
I set up a trigger to simply write to the debug log the value for trigger.isExecuting. I then created a page/class where the action method created a new account, and opened the page while running an active debug log. After viewing the log, the value of trigger.isExecuting was true.
I thought as much...So this would not help the OP as is appears the OP wanted to know if the trigger was called fired as a result of something a class was doing....
While it is good info, I am curious to know when the iExecuting() would be used....I fail to see a reason to check if I am running while I am running......
Yeah, that's why I had to run the test to know the outcome. I've never used it before, or even thought of a use.