You need to sign in to do that
Don't have an account?
Clifford
Message Edited by Clifford on 05-13-2008 09:09 AM
Order of execution of a Trigger and Workflow Rule
I have a custom object. When a Task is added to the custom object I need to do two things. 1. Check the subject of the Task. If it is a certain value, I have to update the parent custom object status field. 2. I also need to call an external web service if the custom object status field has been updated to a particular value.
I am not able to update the custom object status field using a work flow rule since the logic is dependent upon the Task object. Because of this I have a trigger and Apex class that updates the custom object status based on the Task subject. I then want to use a work flow to check the custom object status and if the status meets the criteria to send an asynchronous outbound message. I would like to use a work flow to send messages asynchronously.
Problem - the work flow runs before the trigger, so even if the trigger updates the status to a value that would make the work flow rule evaluate to true, the work flow runs AFTER the trigger.
Questions:
1. Is there a way to change the order of execution for the trigger and work flow?
2. Can I call a work flow from a trigger or Apex class?
3. I know I can make a synchronous call to a web service from an Apex class, but aside from a work flow is there another way to make an asynchronous call?
Thanks in advance.
Cliff
Message Edited by Clifford on 05-13-2008 09:09 AM
Nope. The triggers always run before workflow.
You kind of can -- if you touch a different object that triggers workflow on it. But not on the exact same object, since by then you're already in the execution chain for that object.
Not yet, but I believe it's coming soon in a future release.