function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Emmanuel B.Emmanuel B. 

problems with use TODAY in time based workflow

Hi,

I have made a worflow rule to send an email to a user when he is late in one step of a program.

The Rule Criteria is
(MyStepObject: Status not equal to Complete) and (ProgramObject: Status not equal to Timed out) and (MyStepObject: FieldToUpdate not equal to null) and (ProgramObject: EndDate greater or equal TODAY)

When the record meets the criteria (typically when it's created), it creates Time-Dependent Workflow Action 21 Days After MyStepObject: EndDate who updates a field, so that a trigger is run and the email is sent to the user. (it creates in fact after 1 , 7 , 14 and 21 days).

Let's consider that the rule is run when the Step record is created, on october 1st, with Step.EndDate = oct 11 and Program.EndDate=oct 31
A field update is scheduled 21 days after oct 11, which is nov 01
I assumed that since there's in the criteria "ProgramObject: EndDate greater or equal TODAY" this action would not have been done because the criteria would have been tested again before it ran, and TODAY(nov01) < Program.EndDate(oct31)

However, the field was updated on nov 01 at 23:00 (and the mail sent).

Can anyone explain me why ?

Thanks for your help

Best Answer chosen by Emmanuel B.
James LoghryJames Loghry
Is your workflow rule criteria set to "When the object was created" or "When the object was edited, but did not previously meet the criteria"?

Also, when was your record created or last updated to meet the criteria?

Whenever that was, I assume it was before October 31st.  If/when this happened, it tells the time based workflow to queue up the workflow for the specified date, which in your case is November 1st.  

All Answers

lakslaks

Hi,

Nov 01 is greater than Oct 31 as per the calendar right ? Was that a typo. If not maybe that's where your problem is.

Your condition might have to be-  ProgramObject: EndDate lesserthan or equal TODAY


Regards,
Lakshmi.
James LoghryJames Loghry
Is your workflow rule criteria set to "When the object was created" or "When the object was edited, but did not previously meet the criteria"?

Also, when was your record created or last updated to meet the criteria?

Whenever that was, I assume it was before October 31st.  If/when this happened, it tells the time based workflow to queue up the workflow for the specified date, which in your case is November 1st.  
This was selected as the best answer
Emmanuel B.Emmanuel B.

Thanks for your answers :

laks : I want the field to be updated only if the program.EndDate is still in the future. So I have to test that Program.EndDate is greater than Today, which was false on Nov 1st since Program.EndDate was the day before. However the field was updated.

James Loghry  :  the criteria is

when a record is created, and any time it’s edited to subsequently meet criteria

but it's true as soon as the object is created. I used this because I needed to be able to run the wrokflow even on previously created records (with an update).

So you're right, the time based workflow was queued before October 31st, but I thought it was evaluated again just before the actions were triggered. But while I'm writing this, I understand that it's not what happens. It's evaluated again every time the record is updated and removed from the queue when the criteria is not met anymore. In this case the criteria is not met anymore because the date changes, not the record, so it's not re-evaluated and remains in the queue.

Thanks, your answer helped me to understand my mistake.