- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2019 01:19 PM
I am building an Automated test and having issues with a date/time field that is required. I need to fill it with a date/time that is always in the future of whenever I am running the test. I have seen several posts for this but none of the suggestions have worked for me. I am fairly new to ServiceNow so it definitely could be me. Any help is appreciated.
Thanks,
Tara
Solved! Go to Solution.
- Labels:
-
Automated Test Framework

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2019 07:12 AM
Hi Tara,
The easiest way I've found to do this is to use something like gs.daysAgo() or gs.hoursAgo() in the date/time field like this:
Using a negative number sets a date in the future, so this would set resolved to two weeks from when the test is run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 10:06 AM
Can we use above line of code in set components value (custom ui) step?
I trying yo set value but not able to set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 10:08 AM
Can we use above line of code in set components value step
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 10:09 AM
Can we use above line of code in set components value step in atf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 01:16 AM
Hi @Brad Tilton ,
I am trying to change the year as well using gs.yearAgo(-365), but its now working . Its remaining to current date and year only . ow to achieve this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2024 10:04 PM
javascript:var gdt = new GlideDateTime(gs.nowDateTime());gdt.addYears(1);gdt.getDate();
use the above line of code for setting the date to next year from current date