- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 12:27 AM
I've got a catalogue item where I want the catalogue task to be created at exactly the date and time of the selected 'end date'. In my workflow, I've got a timer that uses the following code that waits for the selected 'end date' to be reached.
//Wait for End Date to be reached
// Set 'answer' to the number of seconds this timer should wait
answer = gs.dateDiff(gs.nowDateTime(), current.variables.end_date, true);
gs.info('For remove device, the date and time for now is' + gs.nowDateTime() + ' and for end date is ' + current.variables.end_date);
However, what I've noticed is that the catalogue tasks are being created on the selected 'end date' as soon as it goes to midnight:
I was just wondering if there is a way of amending it so that it creates the catalogue task on the date and the time when selected rather than at midnight.
The 'end date' variable is a 'Date' type variable.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 12:43 AM
Hi,
try this
//Wait for End Date to be reached
// Set 'answer' to the number of seconds this timer should wait
answer = gs.dateDiff(gs.nowDateTime(), current.variables.end_date.getDisplayValue(), true);
gs.info('For remove device, the date and time for now is' + gs.nowDateTime() + ' and for end date is ' + current.variables.end_date);
Regards
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
‎05-17-2022 03:18 AM
Thanks very much. That now creates the tasks when the date and time are reached on the end date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 03:24 AM
Please check my below comments.
Regards
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
‎05-17-2022 03:24 AM
Did you mistakenly marked other response as correct?
The answer marked as correct is exactly the same what I mentioned 3hours ago.
Would you mind marking my response as correct since that was the first correct response
Regards
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
‎05-17-2022 03:26 AM
not required.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 03:34 AM