set planned start/end date in test step of ATF

gtk
Mega Sage

we have created a test step on change management module, now our challenge is to set planned start/end date to be dynamic - like if I run the test step in march 3 then the planned start date is set to march 4 and planned end date is set to march 6 like this 

we know it can be done with server script prior to the set field values step, but is there a way to do this in set field values step with help of coding/scripting

any help appreciated

1 ACCEPTED SOLUTION

sai195
Tera Contributor

Hi,

You can use "javascript:gs.daysAgo(-1)" for Planned start date and "javascript:gs.daysAgo(-2)" for Planned end date.

Regards,

Sai

Mark āœ… Correct if this solves your issue and also mark šŸ‘ Helpful if you find my response worthy based on the impact.

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Unless you use custom step which is server side you cannot do this. Set field values for date would give static values to select. Once you create custom step for this and the output variable of that custom step is of type date then it would be showing as an option to select when you use set field values

Mark āœ… Correct if this solves your issue and also mark šŸ‘ Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

sai195
Tera Contributor

Hi,

You can use "javascript:gs.daysAgo(-1)" for Planned start date and "javascript:gs.daysAgo(-2)" for Planned end date.

Regards,

Sai

Mark āœ… Correct if this solves your issue and also mark šŸ‘ Helpful if you find my response worthy based on the impact.

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Sai is right, you should use gs.daysAgo() with a negative number to set a date in the future. Here's a quick example to add for context, in this example I'm setting the Resolved date on incident to 30 days in the future.

find_real_file.png

Nafeesa bashir
Tera Contributor

What if we want to set the value to 2 minutes from now. i tried using minutes instead of days in the formula but it isn't working for my ATF