Timer in workflow based on variable

GB14
Kilo Patron

I am trying to add Timer in the workflow and trigger 7 days before the return date. I tried "A date/time or Duration field" but the variable field is not available to select so I guess I need a script. Also, I went through a lot of posts but unable to find something similar and some didn't work. Any help with the script will be appreciated. 

Requirements are: 

We would like the workflow to trigger 7 days before the return date.
Variable Name "Start_Date"

Thank you 🙂

1 ACCEPTED SOLUTION

If it is date field than set time like. Also make sure you select date which is more than 7 days from now.

var gdt = new GlideDateTime(current.variables.Start_Date); 
gdt.addDaysLocalTime(-7);
answer = gs.dateDiff(gs.nowDateTime(), gdt + " 07:00:00", true);

View solution in original post

12 REPLIES 12

Mike Patel
Tera Sage

On Timer activity and in script section, add below

var gdt = new GlideDateTime(current.variables.Start_Date); 
gdt.addDays(-7);
answer = gs.dateDiff(gs.nowDateTime(), gdt, true);

Hello Mike, 

I just tried this script but it triggered the task right after we submitted the request. 

Thank you 🙂

Is this DateTime field or Date

current.variables.Start_Date

Also share screenshot of timer activity

date

 

find_real_file.png