- 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:36 AM
Would you mind marking my response as correct since that was the first correct response and it worked for you.
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:36 AM
that's because in log you are still not printing the display value
//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.getDisplayValue());
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader