Automated Test Framework: Dynamic Date field populate via javascript: gs.daysAgo not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2018 03:03 PM
Hi I am having an issue in one of my instances where the Automated Test Framework: Dynamic Date field populate via javascript: gs.daysAgo is not working.
Has anyone experienced this problem before?
Here is an example test similar to the one I am working on but scaled down to only show the problem I am facing. I am using a London instance for this example but it also occurs in Kingston Patch 8.
I am opening a record producer.
Setting a date variable.
Instead of inserting the calculated date value it is inserting the text of "javascript: gs.daysAgo(-3)" into the form when the test is run as illustrated in the example screen shot below.
By contrast, a similar approach works correctly for console forms.
Take the following test that sets the valid to field on a knowledge article.
It correctly sets the date for console based forms.
- Labels:
-
Automated Test Framework
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 12:32 AM
Hi Mike,
I tested the above in NewYork and it works well.
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
03-26-2020 02:01 AM
can you try with
javascript:gs.hoursAgo(-7)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2021 06:35 PM
I came across a similar issue and it frustrated me no end. The reason it was happening was that the field being populated was expecting a date/time value, whereas the gs.daysAgo() function provides a date only.
Instead of using gs.daysAgo(-3); try using javascript: new GlideDateTime(gs.daysAgo(-3));
Please mark as helpful if this works for you.