How to created report of incidents opened between last Friday of previous month and 10 days prior ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 01:18 PM
On the first of each month, I need a report to show the P1 incident records which was opened between the last Friday of the prior month and 10 days prior to that date. Any assistance would be appreciated.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 01:53 PM
List filter : sys_id is one of javascript:<script_include>
write your logic inside the client callable script include
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 02:24 PM
Using below link, I came up with below script:
var dayOfWeek_toLookFor = 5; // Friday
var dayOfMonth_toLookFor = 0; // Initializer
// Get last day of the month weekday (Sun=0,Mon=1,Tue=2,Wed=3,Thu=4,Fri=5,Sat=6)
var endOfMonth_weekDay = new Date(new Date().getFullYear(), new Date().getMonth(), 0).getDay();
// Get the current weekday (Sun=0,Mon=1,Tue=2,Wed=3,Thu=4,Fri=5,Sat=6)
var current_weekDay = new Date().getDay();
// Get the last day of the month as a number (28,29,30,31)
var daysInMonth = new Date(new Date().getFullYear(), new Date().getMonth(), 0).getDate();
// Get current day of the month (1-31)
var current_dayOfMonth = new Date().getDate();
if (endOfMonth_weekDay == dayOfWeek_toLookFor) // If last day of month is the dayOfWeek_toLookFor, job done
dayOfMonth_toLookFor = daysInMonth;
else if (endOfMonth_weekDay > dayOfWeek_toLookFor)
dayOfMonth_toLookFor = daysInMonth - (endOfMonth_weekDay - dayOfWeek_toLookFor);
else if (endOfMonth_weekDay < dayOfWeek_toLookFor)
dayOfMonth_toLookFor = daysInMonth - (7 - (dayOfWeek_toLookFor - endOfMonth_weekDay));
var lastMonthLastFri = new Date(new Date().getFullYear(), new Date().getMonth() - 1, dayOfMonth_toLookFor);
var tenDaysBefore = new Date(new Date().getFullYear(), new Date().getMonth() - 1, dayOfMonth_toLookFor - 10);
gs.info(lastMonthLastFri);
gs.info(tenDaysBefore);
*** Script: Fri Mar 29 2024 00:00:00 GMT-0700 (PDT)
*** Script: Tue Mar 19 2024 00:00:00 GMT-0700 (PDT)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 07:26 AM