Workflow Question: What does "Date: NOW" MEAN??

I’m trying to build a workflow where it will send users an email 2 days before the “Due Date” field in “Tasks” module.

I added this condition in my workflow

Modules: Tasks: Due Date LESS THAN OR EQUALS TO Date:NOW - 2 DAYS

But nothing happens…

I’m also wondering what does “Date: NOW” exactly mean?

Jim, an administrator on this forum says “Now” refers to when the workflow runs"

Could someone elaborate this further? What does “when the workflow runs” mean? The date / time when the Workflow is set to “active”? or?

I’m really confused about this part. I assumed that “Now” meant the current date & time.

I think that you should try now + 2 days

Now means now so if you want that something triggers two days before the date of the field you should do something like:
date field >= now + 2 days

Think about your logic: date field <= now - 2 days means 2 days after the date (two days before now)

1 Like

Thank you for your response. I did exactly what you said and sadly, it didn’t work.

To test this, I replaced “2 days” with minutes instead because I don’t want to wait a day or two just to see if this works or not.

I also did exactly what the admin said in this thread and that didn’t work either.
https://suitecrm.com/forum/suitecrm-7-0-discussion/5575-suitecrm-7-2-2-workflow-not-triggering-email-15-minutes-after-lead-creation

My other workflow conditions works fine but I just can’t get this to work for the “Due Date” in Tasks Module. Do you have any other suggestions?

When testing you should check also the interval at which the cronjob of your workflow runs Possibly two minutes may be too small to see it working. I will do a test too and will let you know

1 Like

Thanks! I’ll try “1 hour” “5 hours” and other settings to see if it works.

Well sadly it didn’t work. Anyone have any other ideas or is the workflow broken for the Tasks module.

I want to do something similar as well with opportunities (send email 10 days before expected close date) but I cannot get it to work either. Have tried everything under the sun. I wish there would be a comprehensive guide on workflows because many things that I have tried do not work.

  1. Have you set cronjobs correctly?

  2. Can you check in Admin->Sceduler->Process Workflow Task and look at the Job Log listing at the bottom of the page. You should see the execution time and the job status.
    You have to understand if the workflow has run

  3. Workflow triggering logic
    Here I am trying to provide a simple example.

a. We have a field called Due_Date and it is set at an imaginary date 15
b. Today is day 0
c. We want to create a workflow to send a reminder 10 days before Due_Date
d. We want to create a workflow to send a message 3 days after Due_Date

For Workflow c. we set our condition: Due_Date <= now + 10 days
. Since today is 0 the condition will evaluate to Due_Date (=15) <= now (=0) + 10 (=10). This statement (15 <= 0+10) evaluates to false so the action is not activated
Tomorrow now will be equal to 1 so the condition will evaluate to 15<= 1+ 10 which is FALSE
The day after tomorrow now will be equal to 2 so the condition will evaluate to 15<= 2 + 10 which is FALSE
After one more day now will be equal to 3 so the condition will evaluate to 15<= 3 + 10 which is FALSE
After one more day now will be equal to 4 so the condition will evaluate to 15<= 4 + 10 which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 5 + 10 which is TRUE so our workflow will trigger the action!

For Workflow d. we set our condition: Due_Date <= now - 3 days
We start over from the beginning so today is back to 0 so the condition will evaluate to Due_Date (=15) <= now (=0) - 3 (=3). This statement (15 <= 0 - 3) evaluates to FALSE so the action is not activated
Tomorrow now will be equal to 1 so the condition will evaluate to 15 <= 1 - 3 (=-2) which is FALSE
The day after tomorrow now will be equal to 2 so the condition will evaluate to 15 <= 2 - 3 (=-1) which is FALSE
After one more day now will be equal to 3 so the condition will evaluate to 15<= 3 - 3 (=0) which is FALSE
After one more day now will be equal to 4 so the condition will evaluate to 15<= 4 - 3 (=1) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 5 - 3 (=2) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 6 - 3 (=3) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 7 - 3 (=4) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 8 - 3 (=5) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 9 - 3 (=6) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 10 - 3 (=7) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 11 - 3 (=8 ) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 12- 3 (=9) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 13- 3 (=10) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 14- 3 (=11) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 15 - 3 (=12) which is FALSE (by the way this is the Due_Date but the workflow is not activated yet!)
After one more day now will be equal to 5 so the condition will evaluate to 15<= 16 - 3 (=13) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 17 - 3 (=14) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 18 - 3 (=15) which is TRUE so the worflow will trigger the action

Sorry for being so long but I hope you understood the logic of using Now and a due date.
Now obviously refers to the date in which the workflow is run. This happens everytime the cronjob runs the workflow task.

I hope this was useful to clarify your purpose.

I am sorry, but, since I did a cut and paste for my second logic example, I forgot to update the value of now starting from day 6 of the example so you should change “now will be equal to 5” in each line to the respective day (6, 7, 8, 9, 10, 11, 12, 13, …, 18).

To make it clearer I am copying the correct text below:

For Workflow d. we set our condition: Due_Date <= now - 3 days
We start over from the beginning so today is back to 0 so the condition will evaluate to Due_Date (=15) <= now (=0) - 3 (=3). This statement (15 <= 0 - 3) evaluates to FALSE so the action is not activated
Tomorrow now will be equal to 1 so the condition will evaluate to 15 <= 1 - 3 (=-2) which is FALSE
The day after tomorrow now will be equal to 2 so the condition will evaluate to 15 <= 2 - 3 (=-1) which is FALSE
After one more day now will be equal to 3 so the condition will evaluate to 15<= 3 - 3 (=0) which is FALSE
After one more day now will be equal to 4 so the condition will evaluate to 15<= 4 - 3 (=1) which is FALSE
After one more day now will be equal to 5 so the condition will evaluate to 15<= 5 - 3 (=2) which is FALSE
After one more day now will be equal to 6 so the condition will evaluate to 15<= 6 - 3 (=3) which is FALSE
After one more day now will be equal to 7 so the condition will evaluate to 15<= 7 - 3 (=4) which is FALSE
After one more day now will be equal to 8 so the condition will evaluate to 15<= 8 - 3 (=5) which is FALSE
After one more day now will be equal to 9 so the condition will evaluate to 15<= 9 - 3 (=6) which is FALSE
After one more day now will be equal to 10 so the condition will evaluate to 15<= 10 - 3 (=7) which is FALSE
After one more day now will be equal to 11 so the condition will evaluate to 15<= 11 - 3 (=8 ) which is FALSE
After one more day now will be equal to 12 so the condition will evaluate to 15<= 12- 3 (=9) which is FALSE
After one more day now will be equal to 13 so the condition will evaluate to 15<= 13- 3 (=10) which is FALSE
After one more day now will be equal to 14 so the condition will evaluate to 15<= 14- 3 (=11) which is FALSE
After one more day now will be equal to 15 so the condition will evaluate to 15<= 15 - 3 (=12) which is FALSE (by the way this is the Due_Date but the workflow is not activated yet!)
After one more day now will be equal to 16 so the condition will evaluate to 15<= 16 - 3 (=13) which is FALSE
After one more day now will be equal to 17 so the condition will evaluate to 15<= 17 - 3 (=14) which is FALSE
After one more day now will be equal to 18 so the condition will evaluate to 15<= 18 - 3 (=15) which is TRUE so the worflow will trigger the action

Thanks for the explanation.

What do you mean by set up cronjob?

I checked Admin - Scheduler and my workflow is set to “run as often as possible” but it says “Last successful Run: NEVER” and the Job Log is empty…

My other workflows work just fine so I’m not sure what exactly is wrong here.

Yea same here… tried everything and nothing worked… pretty upsetting to be honest.

I guess that you haven’t set the crontab entry

If you go to Admin -> System section -> Scheduler
You will se at the bottom of the page the following:

To Setup Crontab
Note: In order to run Sugar Schedulers, add the following line to the crontab file:

          • root cd /var/www/vhosts/mydomain/subdomains/mysubdomain/httpdocs; php -f cron.php > /dev/null 2>&1

(Note that I have modified this latter line to something meaningless. You should use the actual line you see).

Then, depending on your system and panel (if any) you have to set your crontab entry.
For example if you have cpanel it is normally fairly easy. Similarly if you have Unix shell access it is also fairly easy. But it really depends on your system and the level of access you have. There are lots of posts in the forum and you can also find out through yout hosting provider as well as google.

Thanks for taking the time to help out amariussi.

Just to be clear, the cronjob and the workflow are running fine. I should’ve gone into more detail, but my issue is the following:

I setup the workflow with “run on” set to “All Records” and “Repeated Runs” unchecked. The condition is “Expected Close Date, Less Than or Equal To, Date, Now + 1 Days”. On a new record, the workflow will “catch it”, I receive the email notification and you see the “Process Audit” record on the workflow’s detail page.

The problem lies with the record being modified with a new “Expected Close Date”. When this new date meets the workflow criteria, it does not trigger the workflow action(s). My guess is because the workflow already processed that record and ignores it??? With that in mind, I tried with “Repeated Runs” checked on, but the workflow action(s) are triggered every time the workflow job runs (which is not what we want).

I will try and create a separate workflow record with “run on” set to “Modified Records” and see if that one will catch modified records but doesn’t that defeat the purpose of the “All Records” value?

You could also try to create an extra field acting as a flag which you unset/set with your other workflows so, even if you run the same workflow repeatedly, it won’t trigger unless the flag is set to TRUE (or whatever you want it to be). If TRUE or FALSE is not significant you could use a numeric value indicating a state or another condition.
I think that you only have to think of a way to create the right conditions for your workflow(s) to trigger in this case.

I will see what happens overnight if my extra workflow set to modified records works. I understand your solution but in the end that requires an extra workflow as well to set/unset the custom flag field. I will post my results tomorrow.

Well things did not go as planned which leads me to think there is definitely a bug in the workflow module.

I have 5 opportunities setup and they should all have been processed by either one of the 2 workflows I have. What ended up happening was 1 existing opp was caught by both and another (which was a new opp) by the new “Modified Records” workflow.

Based on my previous experience with workflows, it looks like the repeated flag has to be on if you want to always catch modified records. In the past I’ve done this by adding the condition on “Date Modified, Equal To, Any Change” in order to avoid having the action triggered every time the workflow job runs.

I will test this theory and report back.

Unfortunately that did not work either. The added condition of “Date Modified, Equal To, Any Change” on my repeated run workflow did not work. I wish I had the time to step through the workflow logic but I don’t. I guess in a situation like this you have to use a custom flag variable which is unfortunate.

I am encountering same problem now. Have you get your issue resolved?

Thanks.

You have to use a custom flag field that gets set when the condition you want occurs and then create another workflow to reset the flag when the record is modified. This will allow the original workflow (with repeated runs checked on) to pick it up again.