[SalesForce] Should time-based workflows trigger upon record update that puts trigger date in the past

I ask because I'm getting conflicting info from the SF documentation

On the one hand:

What happens if I update the value of a date field used in a time trigger?
If you update the date field used in a time trigger, Salesforce recalculates the time trigger as long as the time trigger has not yet fired and the recalculation does not reschedule the time trigger to a date in the past.

source: https://help.salesforce.com/apex/HTViewSolution?id=000005245&language=en_US

On the other:

If Salesforce recalculates the time triggers to a date in the past, Salesforce triggers the associated actions shortly after you save the record.

and

If a workflow rule has a time trigger set for a time in the past, Salesforce queues the associated time-dependent actions to start executing within one hour.

source: https://help.salesforce.com/HTViewHelpDoc?id=workflow_time_action_considerations.htm&language=en_US


My real life situation involves a time-based workflow on opportunities, that fire two different email alerts, one at 90 days and another at 30 days before our custom 'expiration date' field. Pretty straightforward, and the only criteria on the rule is that the opps be a specific record type.

My workflow rule

This rule worked just fine whenever an opp was created after the rule was put in effect, as the trigger date on the opp would always be some point in the future.

But we had a few old opportunities that were in the system, and hadn't been updated since before the workflow went into effect, so as expected they hadn't triggered the workflow. But I did expect the workflow to fire once I went in them and edited the date field that the workflow is based on. Two things to note about that:

  • The 'edit' I made was just to replace the date field with the exact same date as before the edit
  • The 'trigger dates' of these opps (ie the 30 day/90 day prior dates) were all in the past when I made the edits

So then, given that I made the edits and the workflow didn't trigger, should I take this as evidence that the first document's claim about handling past dates is true? Or is the second document correct, and I'm doing something else wrong?

Best Answer

The problem is with how you are trying to get the workflow rule to fire. As crop1645 commented, changing the date will not cause the workflow rule to fire. Take a look at this help doc here.

Your workflow rule is set to fire when the record is created, and any time it’s edited to subsequently meet criteria:

(Default) Evaluate the rule criteria each time a record is created or updated.

For a new record, run the rule if the rule criteria is met.

For an updated record, run the rule only if the record is changed from not meeting the rule criteria to meeting the rule criteria.

With this option, the rule can run multiple times per record, but it won’t run when the record edits are unrelated to the rule criteria.

For example, suppose that for an opportunity record to meet the rule criteria, the opportunity probability must be greater than 50%. If you create an opportunity with a probability of 75%, the workflow rule runs. If you edit that opportunity by changing the probability to 25%, the edit doesn't cause the rule to run. If you then edit that opportunity by changing the probability from 25% to 75%, the edit causes the rule to run. With this last edit, the rule runs, because the record is changed from not meeting the rule criteria to meeting the rule criteria.

Since you cannot use the "created, and every time it’s edited" with time-dependant actions, you could toggle the record type of the record to not match and then match the criteria or modify your criteria even temporarily to look at another field that does not match the criteria and then make it match the criteria, like a temporary flag field.

As far as the the help docs, I don't think they are contradicting each other, just misinterpreted. The first doc you quoted had additional detail in that section that states if the date is in the past then it will set it to the next future date, whereas the second one has the same example with an additional line stating if a future date isn't available then it will be set to trigger immediately.

From the first doc:

What happens if I update the value of a date field used in a time trigger?

If you update the date field used in a time trigger, Salesforce recalculates the time trigger as long as the time trigger has not yet fired and the recalculation does not reschedule the time trigger to a date in the past.

For example, if a workflow rule alerts the opportunity owner seven days before the opportunity close date and the close date is set to 2/20/2008, Salesforce sends the alert on 2/13/2008. If you update the close date to 2/10/2008 and the current date is 2/2/2008 or before, Salesforce reschedules the alert for 2/3/2008. The evaluation date of pending actions is ALWAYS reevaluated and updated if necessary irrespective of the rule criteria. Of course, if the rule is evaluated to false, it does not matter as the actions are removed from the queue.

Second doc:

If you change a date field that is referenced by an unfired time trigger in a workflow rule that has been evaluated, Salesforce recalculates the unfired time triggers associated with the rule. For example, if a workflow rule is scheduled to alert the opportunity owner seven days before the opportunity close date and the close date is set to 2/20/2011, Salesforce sends the alert on 2/13/2011. If the close date is updated to 2/10/2011 and the time trigger hasn't fired, Salesforce reschedules the alert for 2/3/2011. If Salesforce recalculates the time triggers to a date in the past, Salesforce triggers the associated actions shortly after you save the record.