1 respuesta
SELF_REFERENCE_FROM_TRIGGER error from Apex indicates that you have attempted to update or delete a record that is already being updated by another trigger.Sometimes we need to update the record of the same object, which is initializing the trigger. This will cause a recursive trigger and throws this exception. For example, suppose you have a self lookup to contact named spouse. You have two contacts, A and B. when you select A as the spouse of B, you want to also update A as the spouse of B. In trigger for A when you update B, it will call recursive trigger.To control/prevent such condition, we need to add a static variable in another class, as this variable will share a single instance, as these transaction has occurred from a single event. This static variable allows the code to execute in the first run. but prevent any run thereafter.