Demo Trigger.isExecuting Context Variable

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;
       }
}

Want to Apply As Content Writer?

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart

Let's get you started!

Interested in writing Salesforce Content?

Fill in this form and we will get in touch with you :)