- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2016 01:58 PM
I have an offboarding workflow that needs to wait to fire Tasks until the 'term_date'. I think i should use the wait for condition but I am not sure of the script that I should use. Can someone assist, please?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2016 02:42 PM
You can use a Timer activity for this.
If you're getting the value from a form field, set the value for Timer based on "A date/time or duration field" and then select your field.
If you're getting it from a variable, set the value for Timer based on "Script", then in the script field use the code below.
answer = gs.dateDiff(gs.nowDateTime(), current.variables.term_date, true);
You can read about gs.dateDiff here. http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#dateDiff.28String.2C_...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2018 04:28 PM
Hi,
Hoping you can help out here - the above works well in the Global scope - however I'm trying to use it in the HR Scope and it produces an error that states 'Function dateDiff is not allowed in scope sn_hr_core. Use GlideDateTime.subtract() instead'.
Not being a scripter I haven't managed to get this to work - would you be able to translate your code above to do the same thing but with the GlideDateTime?
Thanks Carl.