- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2018 05:09 AM
Hi There,
We are currently building some reusable test cases using ATF (Automated Test Framework) Application. We have several test scenarios related to change management where the "Planned Start Date" and "End Date" should be dynamically populated to future date, typically the date and time should be anything between 3rd Sunday 09:00 pm PST - 12:00 AM PST.
Is there any javascript available to meet this requirement? I want to populate the 3rd Sunday 09:00 pm PST, in the highlighted area as shown in the attached screenshot.
Please help.
Thanks,
RD
Solved! Go to Solution.
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2018 05:15 AM
Here's one way.
var myDatePicker = Class.create();
myDatePicker.prototype = {
initialize: function() {
},
// Pass in year and month as numbers
3rdSunday : function(year, month) {
var first = 15; // the soonest that the 3rd Sunday can be
var last = 21; // the latest that the 3rd Sunday can be
var gdt = new GlideDateTime();
gdt.setYearLocalTime(year);
gdt.setMonthLocalTime(month);
for (var day = first; day < last; day++) {
gdt.setDayOfMonthLocalTime(day);
if (gdt.getDayOfWeekLocalTime() == 7) {
return day;
}
}
return;
},
type: 'myDatePicker'
};
Usage is:
var dom = new myDatePicker().thirdSunday(2018, 6);
// dom = 17, the date of the third Sunday in June 2018
If you want it to return the entire date (ex. 2018-06-17), simply change the return value in the function to
return gdt.getDate();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2021 07:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 03:58 AM
Thank you so much Chuck. It works!.
Cheers!
RD

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 04:38 AM
I'm glad it worked. Don't forget to mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2018 10:33 PM
Hi Chuck,
Do i run this script using the "Run server side script" step. could you please help me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2018 04:00 PM
Greetings. I am trying to do something similar. I have a catalog item that I want to populate the "required by" date field with a date always a week from today. I added a script include:
var myDatePicker = Class.create();
myDatePicker.prototype = {
initialize: function() {
},
// pass in the number of days in the future
// usage: javascript:new myDatePicker().getFutureDate(3);
// the above will set your date to 3 days in the future
getFutureDate : function(futureDate) {
var gdt = new GlideDateTime();
gdt = gdt.addDaysLocalTime(futureDate);
return gdt.getDate();
},
type: 'myDatePicker'
};
and I'm trying to call it in the field as such:
But it doesn't seem to be setting the date. When I set a validation step looking for 11/22 it's failing. Any help would be appreciated.
Also, I can go into the background scripts module and successfully call the script using:
var gd = new myDatePicker().getFutureDate(3);
gs.info(gd);