- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 10:30 AM
I have a Service Catalog item with a "start date" variable.
I need the workflow associated to the catalog item to create a task 4 days after that "start date".
I would prefer to do this via scripting (which is not an area of expertise).
Any out there able to help with a script?
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2019 06:34 AM
try below
var gdt = new GlideDateTime(current.variables.start_date);
gdt.addDays(4);
answer = gs.dateDiff(gs.nowDateTime(), gdt + ' 07:00:00', true);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 10:45 AM
Hi Rachel,
so you want to wait till 4 days after start date; you can use workflow timer activity based on script
script below:
var gdt = new GlideDateTime(current.variable.start_date);
gdt.addDaysUTC(5);
answer = gs.dateDiff(gs.nowDateTime(), gdt, true);
whenever it begins the 5th day i.e. 00:00:00 the workflow would proceed and create the task; so I have added 5 days to the date variable
if you are in scoped application then gs.nowDateTime() won't work use this instead
new GlideDateTime() instead of gs.nowDateTime()
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 12:00 PM
Hi Ankur,
I am in the process of testing this now however I forgot to mention that the variable is part of a variable set.
Would I still use "var gdt = new GlideDateTime(current.variable.start_date);"?
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 12:12 PM
Yes, It doesn't matter if variable is part of variable set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 12:22 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 12:52 PM
there is a typo in calling variable . it should be
current.variables.start_date