Automated Test Framework: Dynamic Date field populate via javascript: gs.daysAgo not working

michael_j_pears
Kilo Explorer

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. 

find_real_file.png

find_real_file.png

 

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. 

find_real_file.png

 

By contrast, a similar approach works correctly for console forms.

Take the following test that sets the valid to field on a knowledge article. 

find_real_file.png

find_real_file.png

It correctly sets the date for console based forms. 

find_real_file.png

7 REPLIES 7

Hi Mike,

I tested the above in NewYork and it works well.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

gtk
Mega Sage

can you try with 

javascript:gs.hoursAgo(-7)

Chris K1
Tera Contributor

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.