Is it possible to cause a workflow rule to fire from a trigger? I would like to send an email to a group when the Owner
field is changed to a specific value on the PSR
object. But I'm getting the following error when trying to use that criteria in a workflow rule:
2 Answers
Yes it is absolutely possible to execute workflow rule after the trigger execution. Please read my blog post to understand the order of execution.
There is an existing issue which states Workflow does not use current value for "Owner:Queue.QueueName" in recursive evaluation if Owner was changed in prior evaluation link
Keep your eyes open for the resolution of this issue. As of now the only resolution you have is refer to the Queue by Id in the workflow formula criteria, like : OwnerId <> "00G4100000xxxxx", etc.
-
Thanks for the helpful info! Do you know what the apex code would look like to fire a workflow rule from a trigger? Commented Dec 29, 2018 at 0:04
-
Apex code will not specifically call the workflow. It is just that the changes made by Trigger is causing the Workflow to execute which is changing the Owner of the record in your case. Commented Dec 29, 2018 at 0:05
My college came up with an alternative solution. I don't need to know the exact prior value, just that the current value is the queue and the previous value is not equal to the current value. New workflow rule criteria:
AND(
IsChanged( OwnerId ),
Owner:Queue.QueueName = "Presales_East_Queue",
PRIORVALUE(OwnerId) <> OwnerId
)