0

I have a time based WF rule which runs based on 'Effective To' field value on a record. and there is a after update trigger on the same object.

Wen I manually update the record(status field), it fires the trigger correctly but trigger is not firing when the time based workflow rule updated the record. I can see updated value on record and last modified datetime as well but no traces of trigger in the debug logs. The trigger does not seem to fire.

From order of execution, I can see the before and after triggers fire again when a WF rule makes a field update on record. So why its not working in my case?

1
  • 1
    It would be helpful if you shared the source of the trigger (and its helper, if appropriate). – Sander de Jong Sep 1 '20 at 10:25
0

Consider checking the workflow.. is it set to reevaluate, because if yes, then Time-dependent actions aren't executed for a reevaluated workflow rule in the following situations:


The reevaluated workflow rule’s immediate actions cause the record to no longer meet the workflow rule criteria.
An Apex after trigger that is executed as a result of a workflow or approvals action causes the record to no longer meet the workflow rule criteria.


To further clarify check this link.

Time Trigger Processing

Time-dependent actions aren’t executed independently. They’re grouped into a single batch that starts executing within one hour after the first action enters the batch.

Note NOTE Actual execution may be delayed based on service availability.

Apex triggers that fire as a result of time-dependent actions may get executed in a single batch or independently.

Follow these best practices:

  • In case they fire independently–Ensure that your Apex logic is scoped for a single scheduled action. For example, don't use Apex static variables to communicate state across Apex code triggered by different scheduled actions.

  • In case they fire in a single batch–Be aware of how the combination
    of your time-dependent actions and Apex triggers impact your Apex
    governor limits.

I hope this helps.

Cheers

3
  • Hi Tushar, Thanks for the explanation here. My WF rule doesn't have any immediate actions, only one time dependant workflow is there. Also the After Update trigger is to update a different object records. After WF rule updates records of say object1, trigger should fire because it checks for any object1 records that have been updated specifically the status field. And this After Update trigger would update associated records of object2. – Ashish Sep 1 '20 at 13:15
  • @Ashish I tried to implement your scenario on Account & contact. My WFR is on a custom date field on Account. And a Time-Dependent Workflow Actions which is like this 0 Hours After Account: Last Modified Date. This modifies Industry field to 'Apparel' which then executes an After Trigger to update the name of the associated contact. And to further give a check I kept an Email Alert on time-dep action. And all this is working fine, I received the mail and field updated after 2-3 mins if creating the record....[1] – Tushar Saxena Sep 1 '20 at 14:41
  • .... I have used the time Last Modified Date to check the actions with no time. As mentioned in the answer Actual execution may be delayed based on service availability. Try to add an email alert or change the time criteria to just check if the workflow is all fine. [2] – Tushar Saxena Sep 1 '20 at 14:43

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.