- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2020 10:52 AM
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 🙂
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2020 11:30 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 02:08 AM
Hi @Mike Patel ,
I am working on similar issue based on your script it's working.
In my requirement,i have one variable called due date which is selected by user, if user selects below 7 days then notification is triggering,if user selects more that 15 days then timer activity is working.
so is there any condition is there only if today is 15 days before of due date(which is given by user)then email should be trigger.
Thanks,
Gopi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 05:02 PM
just change it to -15 instead of -7
gdt.addDaysLocalTime(-15);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2023 06:13 AM
Hi @Mike Patel,
Your solution was very helpful and led me in the right direction. The only question I have now is how do I set the timer to expire exactly 24 hours (-1) before the variable used (in my case, it's date_needed). The 07:00:00 appears to be adjusting the time and causing the timer to set at a different time. I would prefer that it just expires/generates the task exactly 24 hours before date_needed that the requestor enters.
You help is appreciated - Thank you!