Reply
Regular Contributor
jochen5478
Posts: 13
0
Accepted Solution

execution order of workflows, apex trigger and validation rules

Hello,

I'm sure this question has been asked from time to time, but I could not find the answer with my search strings:
Is there a specified execution order of apex triggers, workflow rules and validation rules?
I have some problems that depend on this execution order and need to know in wich squence these were executed.

Thanks for your help!
Jochen
Trusted Contributor
TA_Invisible
Posts: 200
0

Re: execution order of workflows, apex trigger and validation rules

From Help and Training:

Salesforce processes any rules in the following order:

  1. Validation rules
  2. Assignment rules
  3. Auto-response rules
  4. Workflow rules (with immediate actions)
  5. Escalation rules

Workflow field updates that run based on an approval process or time-dependent action do not trigger any rules.

As a side note, formula fields are processed between 1 and 2. Someone else will have to reply about Apex triggers, I'm not certain.
Super Contributor
werewolf
Posts: 3,520
0

Re: execution order of workflows, apex trigger and validation rules

The order of execution (with Apex) is as follows:

1. All before triggers execute
2. System validation occurs, such as verifying that all required fields have a non-null value, and running any user-defined
validation rules
3. All after triggers execute
4. Assignment rules execute
5. Auto-response rules execute
6. Workflow rules execute
7. Escalation rules execute
8. Post-commit logic executes, such as sending email
Contributor
GeorgeK
Posts: 8
0

Re: execution order of workflows, apex trigger and validation rules

Anyone have any ideas around how to order workflows rules (with immediate actions) that are related to a custom object. We have a record get created via the API and assigned to a queue then we have 2 workflows that need to immediately kick-off but in a specific order.
1) Change the Owner of the record
2) Fire off an email
 
#2 has to happen after #1 because the email template needs to populate with the new record owner information on it. Any ideas are greatly appreciated.
Regards,

George
Regular Contributor
apexsutherland
Posts: 72
0

Re: execution order of workflows, apex trigger and validation rules

X-Squared On Demand has the full salesforce order of execution list from the Apex documentation posted here:

http://www.x2od.com/2008/11/09/salesforce-order-of-execution.html

oe
Contributor
oe
Posts: 4
0

Re: execution order of workflows, apex trigger and validation rules

Hi George,

 

I have the same problem... Did you resolve it?

 

Thanks,

Beatriz

Regular Contributor
jochen5478
Posts: 13
0

Re: execution order of workflows, apex trigger and validation rules

Hi Beatriz,

 

I think you should use a kind of synchronization mechanism. You could create a further custom field lets call it sync__c.

The first workflow gets a second imdiate field update and sets sync__c to true. The second workflow rule looks for sync__c equals true and fires the email (or what ever you like). The second workflow has to reset the sync__c to false with an other imdiate field update.

 

Lets take again George example. If the change of ownership will only be triggered by this first workflow you could use the ISCHANGED(OwnerId) function in the secound workflow rule to make sure the ownerid has been changed. This would be a kind of synchronization mechanism as well.

 

Greetings,

Jochen

Contributor
new joiners
Posts: 3
0

Re: execution order of workflows, apex trigger and validation rules

what are escalation rules?

 

in workflow triggers execute first or after workflows plz help me i want to know

Visitor
mubarak_alam
Posts: 1
0

can we change the order of execution of triggers

HI i just woud like to know that cn we change the order of execution of triggers..while executing??