0

I have a before update/insert trigger on Contact

trigger ContactTrigger on Contact (before insert, before update) {

    for(contact con:Trigger.New){
        If (con.FirstName ==con.LastName){
            con.FirstName='Default';
            con.Level__c = 'Primary';
        }
    }
}

Also, I have a process builder, on contact object that triggers on record update/insert

Condition : Level = Primary (not marking the advanced check for specific change to occur to invoke process builder)

Action:

  1. Change FirstName = LastName
  2. Add a case and assign it to this contact.

Now, I am adding a contact with First name ='test' and last Name = test'

The record gets saved as 'Default test' with one case created and assigned.

Thus order of execution : Trigger --> process builder --> Trigger

I was expecting this to get into recursion issue. But it is not. May I know the reason? I am just trying to understand the order of execution.

  • I have checked the flag "Recursion" as True in the adavanced section of "Choose Object and Specify When to Start the Process" on my process builder. Still the results are same. – Nitish Agrawal Mar 5 at 12:56
1

I believe the order of execution you're seeing runs like this:

  1. Trigger goes off. First name is set to 'Default' and Level to 'Primary'
  2. Process executes. First name is set to 'Test' and Case is created.
  3. Trigger is executed again. First name is set to 'Default'.
  4. Process is configured not to evaluate a record multiple times in a transaction, and hence does not execute because it has already processed this record.
  5. Transaction commits.

You do have recursion, but Process Builder's configuration is preventing it from running away and causing a limit exception.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.