We often find ourselves in a situation where a specific code block that is stringed together in trigger which should not be executed in batch mode. The reason might be that batch execution might be triggering more number of triggers and hit any given governed limits. To achieve this in there is a method available in System class.
- !system.isBatch() – available for more information in this page
- Example Code Block: include this method in classes involved in trigger context to avoid executing in batch context.
if(!System.isBatch()) {
//call service class
}
1 comment