In the salesforce order of execution diagram it is mentioned 'is this a recursive save?' what does it mean? If possible please provide an example enter image description here

1 Answer 1


In programming, "recursion" is when a thing calls itself.


public Integer fibonacci(Integer arg1) {
    // The "base case(s)", which is what controls when the recursion ends
    if(arg1 == 0 || arg1 == 1){
        return 1;

    // The "recursive case", where we call ourselves
    return fibonacci(arg1 - 1) + fibonacci(arg1 - 2);

So if you take that concept, and apply it to triggers, that would mean an operation which causes a trigger to run, and then something happens that causes it to run again.

I believe that the Order of Execution (OoE) diagram from architect.salesforce.com that you've referenced here is specifically referring to when you have a workflow rule (which are deprecated) with a "field update" action or a process builder (also deprecated) with a "field update" immediate action, or an after-save, record-triggered flow with a "field update" immediate action. In those cases, the same record(s) will undergo another "save procedure". Since that causes the same record to go through the trigger again, it is recursive.

There are other types of recursion that aren't covered by Salesforce's narrow definition in that diagram, such as:

  • Inserting a new record of a given SObject inside of a (before or after) Insert trigger
  • Updating a record contained within trigger.new or trigger.newMap inside of an Update trigger (while Salesforce does generally prevent this, there are ways around it)
  • Indirect recursion/looping, like when you have an Insert trigger that updates a record, and an Update trigger that inserts a record

I believe the "recursive save" part of the diagram, which skips certain parts of the OoE, only applies to updates that happen because of workflow/process builder/flow. The other cases that I mentioned should still go through the entire OoE, and you'll run into an exception if you get more than 16 levels deep into the recursion (if you don't run into a governor limit first).

Getting 16 levels deep into trigger recursion generally means that you've missed a base case, and Salesforce has prevented you from running an infinite loop.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .