SELF_REFERENCE_FROM_TRIGGER: object is currently in trigger execution
What does this error mean?
This error occurs when a Salesforce trigger attempts to update the same record that fired the trigger. Since the record is already in the trigger context, Salesforce blocks the operation to prevent infinite recursion.
Triggers must avoid performing DML operations on the same records within the same transaction.
Common Causes
1. Updating the same record in a trigger
The trigger updates records that already exist in Trigger.new.
2. Recursive trigger logic
Triggers that update records repeatedly can cause recursive execution.
3. Workflow or flow updating records
Automation may trigger additional updates causing recursion.
How to Fix It
Solution 1 — Use a static recursion guard
public class TriggerHelper {
public static Boolean isRunning = false;
}
Solution 2 — Prevent trigger recursion
trigger AccountTrigger on Account (before update) {
if(TriggerHelper.isRunning){
return;
}
TriggerHelper.isRunning = true;
for(Account acc : Trigger.new){
acc.Description = 'Updated';
}
}
Solution 3 — Move logic to before triggers
Where possible, update field values in before triggers rather than performing additional DML operations.
Pro Tip: Always design triggers using a trigger framework or recursion guard to prevent infinite loops.