This example showcases the use of the Trigger.isExecuting
context variable to determine whether a call is from a trigger context or another source, enabling context-aware logic execution.
For detailed examples, explore this YouTube playlist.
Solution:
public class AccountHandler{ public Boolean
handleAccount(List<Account> accList){
System.debug(‘Trigger is executing : ‘ + Trigger.isExecuting);
if(Trigger.isExecuting)
//do whatever you want to do as part of the trigger invocation
}
else{
//do whatever you want to do if the call originated from a different context, such as from the controller.
}
return Trigger.isExecuting;
}
}