4

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?

2
  • 1
    hard to see in the screen shot but it looks like the WF criteria is Record Type = xx - changing the date won't make the 'subsequently edited to meet criteria' condition true and the workflow won't execute
    – cropredy
    Dec 6, 2014 at 1:14
  • Ah, I see what you're saying. Ok, that explains the rule not firing. But what do you make of the conflicting documentation about what happens when a rule fires and the trigger date is in the past?
    – smohyee
    Dec 7, 2014 at 20:13

1 Answer 1

6

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.

6
  • OK, got it, thanks! But same question for you as crop1645: what do you make of the conflicting documentation about what happens when firing a rule with a past trigger date?
    – smohyee
    Dec 7, 2014 at 20:16
  • 1
    Added more to the answer but from how I understand the docs they both say the same thing. They will trigger but will never pick a date in the past, can only be a date greater than today, if no date is available then it will happen immediately (within an hour).
    – Jenny B
    Dec 7, 2014 at 23:12
  • Thanks for following up Jenny...That's what I figured would happen, but it doesn't seem to be working! Here's what I did: I added a flag field, and changed my rule criteria to "is of record type X AND has flag field set to true". Then I went and updated all the opportunities and had their flag field set to true. I figured this would cause all the opps with trigger dates in the past to fire off the email alert right way. But alas, no email alerts!
    – smohyee
    Dec 8, 2014 at 18:48
  • Do you see them listed in setup under monitor -> Time Based Workflow?
    – Jenny B
    Dec 8, 2014 at 18:51
  • @smohyee I didn't at mention you, so not sure if you saw my last question? After you flag the record, did you check the Monitor section to see if it shows up in the Queue, it wouldn't normally email immediately but typically within an hour.
    – Jenny B
    Dec 9, 2014 at 16:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .