- 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
‎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
‎08-07-2020 11:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 08:59 AM
Thanks Mike.
had to make a minor change and then the script worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2020 07:39 AM
Thank you very much. How it will work if the start date is within 6 days? Do we need to add any If conditions?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2020 07:41 AM
No, If the date is less then 7 days then it will skip the timer so no condition is needed.