- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 12:30 AM
Hi,
I need to populate planned start date and end date based on selecting ci, the 3rd Friday date should be auto populate
Need an urgent help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 12:49 AM
Hi @Amit Kumar13
Try the below script. it'll give you the 3rd Friday of the current month.
Modify the script as required.
var gdt = new GlideDateTime();
var year = gdt.getYear();
var month = gdt.getMonth();
var str = year + "-" + month + "-01 00:00:00";
var date = new GlideDateTime(str);
var fridayCount = 0;
while (fridayCount < 3) {
var dayOfWeek = date.getDayOfWeek(); // 6 = Friday
if (dayOfWeek == '5') {
fridayCount++;
if (fridayCount == 3) {
break;
}
}
date.addDays(1);
}
gs.print(date.getDisplayValue());
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 12:49 AM
Hi @Amit Kumar13
Try the below script. it'll give you the 3rd Friday of the current month.
Modify the script as required.
var gdt = new GlideDateTime();
var year = gdt.getYear();
var month = gdt.getMonth();
var str = year + "-" + month + "-01 00:00:00";
var date = new GlideDateTime(str);
var fridayCount = 0;
while (fridayCount < 3) {
var dayOfWeek = date.getDayOfWeek(); // 6 = Friday
if (dayOfWeek == '5') {
fridayCount++;
if (fridayCount == 3) {
break;
}
}
date.addDays(1);
}
gs.print(date.getDisplayValue());
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 12:50 AM
hi @Amit Kumar13
Create an onChange client script on the cmdb_ci field.
In the script, calculate the 3rd Friday of the current or next month.
Set the Planned Start and End Date fields to that date using g_form.setValue().